in reply to Why won't this socket client terminate?

I tried your script. The while loop just wouldn't work, so I abandoned it and tried it like this.
#!/usr/bin/perl -sl use strict; use warnings; use IO::Socket::INET; my $socket = IO::Socket::INET->new( PeerAddr => '192.168.1.1', PeerPort => 'http(27109)', Proto => 'tcp', ); $socket->accept(); if($socket->connected) { print "This is a test"; } else { print "Sorry! This is not what you wanted\n"; } $socket->close(); sleep 3; unless($socket->connected) { print "This test has closed"; }