use strict; use warnings; use IO::Socket::INET; my $PORT = 53123; my $num = 0; my $sock = new IO::Socket::INET( LocalHost => '127.0.0.1', LocalPort => $PORT, Proto => 'tcp', Listen => 5, Reuse => 1, ) or die; binmode $sock; while ( my $client = $sock-> accept ) { my $str = do { local $/; <$client> }; die "$num\n" unless $str eq '123'; print "$num\n" unless $num ++ % 1000; }