tags:

views:

181

answers:

4

I make a recv call on a TCP socket and it tured out to be that the recv call is a blocking one even though the socket itself has set to be in non-blocking mode. So my question is just as simple as: how to implement a non-blocking recv on a perl socket? thanks in advance.

A: 

Try passing the MSG_DONTWAIT flag to your recv call.

earl
+2  A: 

Use the 4 argument version of select to check whether there is input on the socket before you try to recv from it.

mobrule
+3  A: 

If your looking for a simpler interface to select mentioned by mobrule IO::Select provides an OO interface to it.

Ven'Tatsu
IO::Socket provides some nice API cleanup as well. I always use IO::Select and IO::Socket instead of the built-in functions. The API is a million times easier to work with.
daotoad
Thanks, it worked great for me too.
Igor Oks