Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > 9bc5442986852b4b0f56543d61a770fc > files > 13

perl-Proc-Fork-0.802.0-2.mga4.noarch.rpm

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.
    } }
}