I have a script which will create a socket connection to a host. It should loop through while the socket connection is active. The problem is that it still continues to loop even if I take down the interface on the host machine. What am I missing (no doubt somthing simple). Any help would be appreciated.

#!/usr/bin/perl

use warnings;
use strict;

use IO::Socket;

my $counter = 1;
my $whileloop = 0;

my $sock = new IO::Socket::INET (
PeerAddr => '10.5.7.33',
PeerPort => '21',
Proto => 'tcp',
);
die "Could not create socket: $!\n" unless $sock;

while ($whileloop < 1) {
       if ($sock) {
               printf "Socket connected\n";
               printf "$counter\n";
               $counter++;
               sleep 2;
       } else {
       my $whileloop = 99;
       }
}
close($sock);
printf "Socket closed\n";


Matt

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to