jeffw has asked for the wisdom of the Perl Monks concerning the following question:

I have a UDP based message server that runs great, 99% of the time. Every now and then the program blocks on this line:
$peeraddr = recv $sock, $buffer, 65507, 0;
I've confirmed that $sock is still defined and that the select allowing this code to be executed is saying there is data on the socket. I really don't want to go non-blocking on a UDP socket handling messages from a few hundred clients (nightmare). Any thoughts?

-- Jeff Walter

Replies are listed 'Best First'.
Re: recv blocks even with data to receive
by Anonymous Monk on Feb 16, 2005 at 03:39 UTC
    Are you sure that select is actually returning that you can read on the socket? Select will also terminate when your program gets a signal, so you have to check that the socket in question is actually in the vector returned by select, even if it's the only thing you pass into select.
      Hrmm... I look at that as well. Thanks for the idea.
Re: recv blocks even with data to receive
by chromatic (Archbishop) on Feb 16, 2005 at 00:42 UTC

    Read fewer bytes at a time?

      I dropped it down to 40KB and restarted the script. Now I get to wait for it to die again (last time it took 2 weeks).
Re: recv blocks even with data to receive
by FitTrend (Pilgrim) on Feb 16, 2005 at 02:19 UTC
    How long has this been going on? Is it causing a memory leak that is slowly killing the machine? Is it consistent when it dies (i.e. every 2 weeks?)
      Consistent? No... Seems more of a swing of mood.