Guys,

How can I check if the remote peer closed my TCP connection?

The following code is OK (taken from the book) because it expects something
to come from the peer:

--------------------------------
use IO::Socket;
$sock = new IO::Socket::INET (LocalHost => 'goldengate',
                                            LocalPort => 1200,
                                            Proto => 'tcp',
                                            Listen => 5,
                                            Reuse => 1
                             );
die "Socket could not be created. Reason: $!" unless $sock;

while ($new_sock = $sock->accept()) {
    while (defined ($buf = <$new_sock>)) {          # Will return undef if
peer closes connection!
        print $buf;
    }
}
--------------------------------

However, how can I check if peer closed when I am not expecting anything
from it?
There is not <$new_sock> in my code. I don't want to block on peer's input.


BrunoF


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to