Leser: 1
7 Einträge, 1 Seite |
1
2
3
4
5
if($socket == $server) {
my $client = $socket->accept();
print "Connected\n";
$select->add($client);
$client->print("Hallo Client\n");
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
while(my @readable = $select->can_read) {
foreach my $socket (@readable) {
if($socket == $server) {
print "Connected:Froschpopo\n";
my $client = $socket->accept;
$select->add($client);
$socket->print("Connected as Froschpopo\n"); # hier ist das Problem
} else {
my $line = $socket->getline;
if(defined $line) {
$line =~ s!\r?\n$!!g;
if(lc($line) eq "quit") {
print "Client quits\n";
delete_socket($select, $socket);
} else {
print "Client says: [$line]\n";
$socket->print("$line\n");
}
} else {
print "Connection closed by client\n";
delete_socket($select, $socket);
}
}
}
}
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
while(my @readable = $select->can_read) {
foreach my $socket (@readable) {
if($socket == $server) {
$select->can_write();
$socket->print("Hallo Client\n");
print "Connected\n";
my $client = $socket->accept;
$select->add($client);
} else {
my $line = $socket->getline;
if(defined $line) {
$line =~ s!\r?\n$!!g;
if(lc($line) eq "quit") {
print "Client quits\n";
delete_socket($select, $socket);
} else {
print "Client says: [$line]\n";
$socket->print("$line\n");
}
} else {
print "Connection closed by client\n";
delete_socket($select, $socket);
}
}
}
}
7 Einträge, 1 Seite |