You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
525 B
Perl

use IO::Socket;
$server = IO::Socket::INET->new
(
LocalPort => 1111,
Type => SOCK_STREAM,
Reuse => 1,
Listen => 5
) or die "Could not create server.\n";
while ($client = $server->accept()) {
unless (defined($child_pid = fork())) {die "Can not fork.\n"};
if ($child_pid) {
while ($line = <$client>) {
print "Read this from client: $line";
}
} else {
while ($line = <>) {
print $client $line;
}
}
}