Hi all,
Thanks to John and Bill, I've managed to get my socket disconnect
detection working.
I'd like to share my check code with all:
my $BytesRead = $sock->sysread($buffer,1024);
if (!defined($BytesRead))
{
print "WARNING: Connection lost!\n";
exit;
}
My next obstacle is with sysread blocking. I tried to do the following:
my $sock = new IO::Socket::INET (
PeerAddr => $ARGV[0],
PeerPort => '8000',
Proto => 'tcp',
Reuse=>1,
);
$sock->blocking(0);
But it still blocks. Browsing the web, David Smith posted the following
code:
my $select = = IO::Select->new();
$select->add( $socket );
if( $select->can_read( 0.5 ) )
{
$response = <$socket>;
print $response . "\n";
} else
{
print "No data on socket.\n";
}
I'd like to ask if using IO::Select is the best/ only way to do a
non-blocking sysread(), or am I missing something?
Thanks.
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs