Leser: 1
|< 1 2 3 >| | 26 Einträge, 3 Seiten |
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
#!/usr/bin/perl
use strict;
use IO::Socket;
use constant MYPORT => 2345;
use POSIX ":sys_wait_h";
#$| = 1;
my $sock = '';
my $client = '';
my ($pid, $PID, $waitpid, );
$sock = new IO::Socket::INET(LocalPort => MYPORT,
Reuse => 1,
Listen => 5) or die "can't create local socket: $@\n";
#sub sigchldHandler {
# $waitpid = wait();
# $SIG{CHLD} = \&sigchldHandler;
#}
#$SIG{CHLD} = \&sigchldHandler;
$SIG{'CHLD'} = sub { wait(); $client ->close; };
print "Accepting connections on Port ", MYPORT, "...\n";
while ($client = $sock->accept()) {
print "Accepted connection from ",
$client->peerhost(), ":", $client->peerport(),;
if (fork() == 0) {
$PID = $$;
print ", PID:$PID\n";
while (<$client>) {
chomp;
print $client scalar(reverse($_)), "\n";
print $client "$PID\n";
}
}
}
QuoteJ-jayz-Z 10.08.2005, 16:51
|< 1 2 3 >| | 26 Einträge, 3 Seiten |