my $count = 0; my @sock; while ($count < 100) { $sock[$count] = IO::Socket::INET->new(PeerAddr => $args{h}, PeerPort => $args{p}, Proto => 'tcp', Type => SOCK_STREAM, Timeout => 10); print "\nCONNECTED TO HOST:$args{h} PORT:$args{p} $count times \n"; $count++; } sleep 10; my $count2; while ($count2 < 5) { shutdown ($sock[$count2], 2); print "Closed $sock[$count2]\n"; $count2++; } sleep 15; }