in reply to Unexplainable Client/Server trouble

UPDATE: I tested the $! after receiving the error from sysread and discovered it's retuning a Broken Pipe. Has anyone else experienced this? I don't understand what would be causing the problem only in the specific functions. Any help or pointers are still appreciated.
-Adam Stanley
Nethosters, Inc.
  • Comment on Re: Unexplainable Client/Server trouble

Replies are listed 'Best First'.
(tye)Re: Unexplainable Client/Server trouble
by tye (Sage) on Apr 03, 2001 at 02:41 UTC

    I thought that "broken pipe" only happened when writing to a pipe (and my quick review of some documentation supports that)...

    But it would make sense that a socket could give you "broken pipe" on read if the connection was broken badly (as opposed to the connection being shut down normally which should just generate "end of file" which sysread will return as 0 and not undef).

    So, for example, the connection timing out or the route to the client being lost (to the point of generating "host unreachable" via ICMP), etc. could probably generate this.

            - tye (but my friends call me "Tye")
Re: Re: Unexplainable Client/Server trouble
by dws (Chancellor) on Apr 03, 2001 at 01:27 UTC
    Let's assume for a moment that "Finished" means that the other end of the socket is declaring that they're done, and that they'll next close the socket. If you have a code path that takes you back through this routine after the other end has closed the socket, you'll see a broken pipe.

    See tye's response below.

Re: Re: Unexplainable Client/Server trouble
by astanley (Beadle) on Apr 03, 2001 at 02:26 UTC
    I've run test from the client side of the connection - the failure in execution stops between two lines ... one of which seems to be executed, the second of which doesn't. The two lines are syswrite and sysread. The write apparently goes through and the server reacts, however when the read is called the script dies - even when run with something like sysread(...) || print "im dying"; The script doesn't output the I'm dying. I've examined $! and the return code of the sysread and both are empty strings. I do not know what else I can do to debug this so hopefully someone will have an idea. Sorry for the hundred posts.

    -Adam Stanley
    Nethosters, Inc.

      Writing to a pipe that has no readers can generate a SIGPIPE signal which will kill your program. You can prevent this with $SIG{PIPE}= 'IGNORE'; and then syswrite will return undef and $! will be "broken pipe".

              - tye (but my friends call me "Tye")