forked from MysteryOfPanda/leactor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.pl
50 lines (42 loc) · 1.07 KB
/
client.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/perl -w
use IO::Socket::INET;
use strict;
use threads;
my $sock = IO::Socket::INET->new(PeerAddr=>'localhost',
PeerPort=>'12344',
Proto =>'tcp',) or die("Failed !");
#$sock->write("test", 10, 0):
#$sock->autoflush(1);
print "connected to the server\n";
<>;
print "wait end\n";
<>;
senddd();
recvvv();
sub recvvv {
threads->create(sub {
threads->detach();
while (1) {
# print "recv S\n";
my $msg;
(defined $sock->recv($msg, 32)) or die "recvF:error<$!>\n";
# print "recv O\n";
# print ">".$msg."\0";
# print "recv P\n";
}
});
}
sub senddd {
threads->create(sub {
threads->detach();
while (1) {
# print "send S\n";
my $data = "send to SERVER:dATA";
$sock->send($data) or die "sendF: $!";
# print "send O\n";
}
});
};
sleep 15000;
print "sleep over\n";
$sock->close();