init
This commit is contained in:
39
client.pl
Executable file
39
client.pl
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use IO::Socket::INET;
|
||||
use Time::HiRes qw( usleep );
|
||||
|
||||
# auto-flush on socket
|
||||
$| = 1;
|
||||
|
||||
# create a connecting socket
|
||||
my $socket = new IO::Socket::INET (
|
||||
PeerHost => 'dagobert.agadmin.de',
|
||||
PeerPort => '7777',
|
||||
Proto => 'tcp',
|
||||
);
|
||||
die "cannot connect to the server $!\n" unless $socket;
|
||||
print "connected to the server\n";
|
||||
|
||||
for ($i=0; $i<=1000000; $i++) {
|
||||
# data to send to a server
|
||||
my $req = "hallohallohallo";
|
||||
my $size = $socket->send($req);
|
||||
#print "sent data of length $size\n";
|
||||
|
||||
# notify server that request has been sent
|
||||
#shutdown($socket, 1);
|
||||
|
||||
# receive a response of up to 1024 characters from server
|
||||
my $response = "";
|
||||
$socket->recv($response, 1024);
|
||||
chomp $response;
|
||||
#print "received response: $response\n";
|
||||
# 1000*1000 = 1s
|
||||
# 1000 = 1ms
|
||||
usleep (10);
|
||||
}
|
||||
my $req = "quit";
|
||||
my $size = $socket->send($req);
|
||||
|
||||
$socket->close();
|
||||
Reference in New Issue
Block a user