Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

My program waits on a Socket for requests
$sock = new IO::Socket::INET ( LocalHost => $host, LocalPort=> $port, Proto=> 'tcp', Listen=> 5, Reuse => 1, );
with an IO::Select. It processes these requests (in their 1000s )and returns them print $soc $reply;

Occasionally, the program dies (either with no warning or just with the message Broken Pipe) I am certain that the problem happens when I try to print back to the requesting socket ( that connects to me
$sock = new IO::Socket::INET ( PeerAddr => $host, PeerPort => $peerport, Proto => 'tcp', );
) even though the requesting socket appears to be in order ( passes $sel->can_write and $sel->exist ) any thoughts?

Replies are listed 'Best First'.
(tye)Re: mevakesh (Socket Question)
by tye (Sage) on Apr 05, 2001 at 23:33 UTC

    First, remove the LocalHost => $host, as it does no good and prevents your service from being available via multiple addresses. For example, you won't be able to test the server by connecting to "localhost".

    I am a bit surprised that you'd need to do this, but you should be able to fix your problem with $SIG{PIPE}='IGNORE';.

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