while ( 1 ) { while (my $r = $sock->accept) { # process } if ($! == &Errno::ETIMEDOUT) { warn "Server runs on a timeout" } }