in reply to IO::Socket disconnects in loop

Hi, I can confirm your observations (SuSE 11.1, perl v5.10.0). Seems that your writer.pl is just too fast and consumes a lot of system resources. When writer.pl dies, netstat -n lists some 26k of TIME_WAIT connections for port 7070. If the client allows the sever some time to recover (I used a select(undef,undef,undef,0.0001); after the $i++ in writer.pl), then there's no problem. Runs, and runs, and runs,....while netstat reports something around 13k TIME_WAIT connections, so a kind of equilibrium has been reached.

Change the die() statement in writer.pl to die "Could not connect - $!\n" unless $socket and run writer.pl without the select(...) delay using:

LANG=C perl writer.pl ; netstat -n | egrep 7070 | wc -l
After a while, writer.pl dies and you'll see something like:
Could not connect - Cannot assign requested address 28248
...meaning, that there were temporarily too few resources left and netstat reported something around 28k connections (nearly all of them in TIME_WAIT state indicating a proper disconnection plus guard time).
Update: After a while, resources become available again and you can re-start writer.pl successfully.

HTH

Replies are listed 'Best First'.
Re^2: IO::Socket disconnects in loop
by carlin (Beadle) on Jun 14, 2009 at 04:13 UTC
    That makes sense. Thank you!