use IO::Socket;
my $use_fork = 1;

my $sock = new IO::Socket::INET (
                                 LocalHost => '127.0.0.1',
                                 LocalPort => '12321',
                                 Proto => 'tcp',
                                 Listen => 1,   
                                 Reuse => 1,
                                )
		or die "socket: $!";	

$SIG{CHLD} = 'IGNORE' if $use_fork;	

print "listening...\n";
while (1) {
	
        my $con = $sock->accept()
		or die "accept: $!";
	fork and next if $use_fork;	

	print "incoming..\n";
	print $con $_ while(<$con>);	
	print "done\n";

	last	if $use_fork;	
}