while( 1 ){ my $paddr = accept( Client, Server ); next if not $paddr; my $buf = ''; eval { local $SIG{'ALRM'} = sub { die "time\n" }; Time::HiRes::alarm( $READ_TIMEOUT ); recv Client, $buf, $MAX_REQ_LEN, 0; Time::HiRes::alarm( 0 ); }; if( $@ ){ # operation timeout / met errors d 'Timeout on read'; close Client; next; } ...