use IO::Socket; use IO::Select; my $sock = new IO::Socket::INET (LocalHost => '127.0.0.1', LocalPort => 1200, Listen => 5, Proto => 'tcp', Reuse => 1, ) or die $!; my $handles = new IO::Select(); $handles->add($sock); while (1){ print "yo"; my ($s_handles) = IO::Select->select($handles, undef, undef, 1); for my $hndl (@$s_handles){ if ($hndl == $sock){ $handles->add($hndl->accept()); } else { if (my $line = <$hndl>){ print $line; } else { $handles->remove($hndl); close ($hndl); } } } }