hi,
i need to write a perl client script to create 5000 socket connections at the same time.
the above script creates only one socket connection at a time........
what should be changed to create 5000 socket connections at the same time.
i need to write a perl client script to create 5000 socket connections at the same time.
Code:
use IO::Socket;
use diagnostics;
use POSIX qw(strftime);
my $i;
my $connections = 5000;
foreach my $i (1...$connections)
{
repeat();
}
sub repeat
{
my $remote_host = "192.168.1.57";
my $remote_port = "1201";
my $count=0;
my $handle= IO::Socket::INET->new( PeerAddr => $remote_host,
PeerPort => $remote_port,
Proto => "tcp",
Type => SOCK_STREAM
)
|| die "Couldn't connect to $remote_host:$remote_port: \n";
print STDERR "[Connected to $remote_host:$remote_port]\n";
DATA: {while(<$handle=1>)
{
for($count=0;$count<5;$count++)
{
my $send_data = strftime("::DATA::3847,%d.%m.%Y,%H:%M:%S,13.0149405,77.7736041,0,933.4,04A8,31,0 \n", gmtime);
$handle-> send($send_data);
$count=0;
sleep(5);
}
}
redo DATA;
}
}
what should be changed to create 5000 socket connections at the same time.
Comment