> You need to use the IO:Select module which makes the ports non-
> blocking.
> When you check the port for reading, it will indicate there is 
> something
> to read. When you read it using sysread if it returns:
> 0 = the socket has disconnected.
> undef = there was an error on the handle, $! has been set to the error
> code.
>  
> So, in short, use the IO:Select module to check the handle BEFORE you
> attempt to read so that it won't block. When there is something to 
> read,
> if sysread returns 0, the socket is disconnected, close it down and
> carry on.
 

Perhaps I'm doing something wrong then. I think I am doing this but when I
close the connection it still takes a couple minutes for it to flush. Here's
where it is happening:

# <snippet>

if ($bufflen==0) {
   CloseSocket($sock);
} else {
   my $l=syswrite($param->{'corresponding_sock'},$buff);
   print LOG "$buff" if ($log == 1);
   if ($l != $bufflen) { die "can't write all data\n"; }
}

# </snippet>

then in sub CloseSocket I do $sock->close() among other things. Hmmm....


_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to