[Israel.pm] receiving undef via socket
guy keren
choo at actcom.co.il
Fri Aug 4 18:50:26 EEST 2006
unix-domain sockets are datagram sockets, not stream-based.
your non-blocking theory could be right, if indeed the socket was set to
non-blocking mode. i assume that the API does not do this by default, so
it has to be done using an explicit call - and i didn't see such a call
in gabor's code.
--guy
On Fri, 2006-08-04 at 12:17 +0300, Roie Marianer wrote:
> > I have an application that is forking clients and talks to them via
> > sockets. Ocassionally the client receives undef via the socket. I wonder
> > why.
> Never worked with Unix sockets before, so I may be way off here, but... is the
> <$sock_to_parent> call in the child nonblocking? Perhaps the child tries to
> read from the parent before the parent finishes writing to the socket, and
> instead of waiting, you get undef.
>
> Also, depending on the circumstances, you may get a partial command
> (especially if the command was very long, but I believe the operating system
> is technically allowed to split even a two-byte message), or two commands (if
> they were short and submitted in rapid succession).
>
> Basically, you seem to be treating a stream-based socket as if it were a
> datagram-based socket, and as you just found out, that doesn't always
> work. :-)
>
> At least, that's my experience with TCP, maybe it's different with Unix
> sockets.
>
> -R
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://perl.org.il/mailman/listinfo/perl
More information about the Perl
mailing list