Try moving the client to a different machine. I used:
Set the two ends going. Disconnect the client machine from whatever network connects them. After a while, the client will give up. The server won't. (You can get the same effect by pulling the plug on the client machine, but I wouldn't recommend that.)#! perl -w use strict; use IO::Socket; my $host = $ARGV[0] ; $|++ ; my $con = IO::Socket::INET->new( "$host\:54321" ) or die "failed to c +onnect: $!" ; while (print $con "ping\n") { print "*" ; sleep 1 ; } ; print "client ended: $!\n";
As far as the server is concerned, this is related to changing the your client to:
except that when you finally get bored and terminate the client, the OS will close the client end of the connection and the server will get to hear about it.use strict ; use IO::Socket ; $|++ ; my $con = IO::Socket::INET->new( 'localhost:54321' ) or die "failed to + connect: $!" ; for (1..20) { print $con "ping\n" ; print "*" ; sleep 1 ; } ; print " client hanging" ; while (1) { print "." ; sleep 60 ; } ;
In reply to Re^7: Non closing sockets - threads
by gone2015
in thread Non closing sockets - threads
by igor1212
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |