use strict; use warnings; use Net::TCP::Server; # create listener my $lh = 'Net::TCP::Server'->new(8000) or die; while (my $sh = $lh->accept) { defined(my $pid=fork) or die "fork: $!\n"; if ($pid) { # parent doesn't need client fh $sh->stopio; next; } # child doesn't need listener fh $lh->stopio; # do per-connection stuff here # read from the socket exit; }