in reply to Re: Local socket model
in thread Local socket model

hmmm...bad news for me then. The perl client is simple. It doesn't use IO::Socket.
#!/usr/bin/perl -w use strict; # simple client use Socket; use IO::Handle; socket(TSOCK, PF_UNIX, SOCK_STREAM,0); connect(TSOCK, sockaddr_un("/tmp/testsock")) or print "ERROR!"; while (defined(my $messg = <TSOCK>)) { print $messg; print TSOCK "Hello server!\n"; TSOCK->flush; }
Both servers work fine with their counter-part (but I wrote them to do that). I haven't tried to change anything to debug the "c<->perl" problem, because I have a hard time understanding what could be wrong (they are just exchanging strings) and thought I would ask here to find out if there is something I'm unaware of.

If I connect the above perl client to the c server, it accepts a new connection, but it does not recieve the "Hello", and the client does not recieve messages from the server.

What could go wrong, considering the c server works fine with connections to other c programs?

Replies are listed 'Best First'.
Re^3: Local socket model
by Illuminatus (Curate) on Oct 07, 2008 at 14:10 UTC
    What string does the C server send after it accepts the connection? It does have a newline in it, right?
      A NEWLINE!!! What's wrong with a good ol' fashioned "null terminator"?!!? wow...thanks.
        Yes, the <> operator is the equivalent of fgets (with an essentially unlimited length value) in C.
        Then perhaps you want to redefine what <> considers a line?
        local $/ = "\0"; # Read up to NUL. while (defined(my $messg = <TSOCK>)) { chomp $messg; # Remove NUL. print "$messg\n"; print TSOCK "Hello server!\n"; TSOCK->flush; }