File: server.pl

package info (click to toggle)
libproc-fork-perl 0.807-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 136 kB
  • sloc: perl: 165; makefile: 2
file content (22 lines) | stat: -rw-r--r-- 455 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use strict;
use IO::Socket::INET;
use Proc::Fork;

$SIG{CHLD} = 'IGNORE';

my $server = IO::Socket::INET->new(
	LocalPort => 7111,
	Type      => SOCK_STREAM,
	Reuse     => 1,
	Listen    => 10,
) or die "Couln't start server: $!\n";

my $client;
while ($client = $server->accept) {
	run_fork { child {
		# Service the socket
		sleep(10);
		print $client "Ooga! ", time % 1000, "\n";
		exit; # child exits. Parent loops to accept another connection.
	} }
}