$server = IO::Socket::INET->new ( LocalPort => 1116, Type => SOCK_STREAM, Reuse => 1, Listen => 5 ) or die "Could not open port.\n"; while ($client = $server->accept()) { # # start a new process for each new connection # my $pid = fork; if( $pid < 0){ die "fork error: $!"; }elsif( $pid == 0){ # # child process # do whatever you want with the connection here # while( my $line = <$client>){ print $line; } close($client); } # # parent falls through to listen for new connections # } # should never reach here #close( $server);