Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^3: UDP Client Multiple servers

by zwon (Monsignor)
on Oct 12, 2012 at 06:30 UTC ( #998612=note: print w/ replies, xml ) Need Help??


in reply to Re^2: UDP Client Multiple servers
in thread UDP Client Multiple servers

That's not really a good idea. You could just set timeout option on the socket after creating it:

use Socket qw(SO_RCVTIMEO); use POSIX qw(:errno_h); ...; my $timeout = pack 'L!L!', $sec, $usec; $handle->sockopt(SO_RCVTIMEO, $timeout); ...; my $res = $handle->recv(...); unless(defined $res) { if($! == EAGAIN or $! == EWOULDBLOCK) { say "time out"; } }


Comment on Re^3: UDP Client Multiple servers
Download Code
Re^4: UDP Client Multiple servers
by brap (Pilgrim) on Oct 12, 2012 at 13:18 UTC

    Does the Timeout parameter to IO::Socket::INET->new() have the same effect as the sockopt() method?

    Maybe another WTDI.

      Not really, despite documentation for IO::Socket::INET says "Timeout value for various operations", Timeout parameter is only used by connect method of IO::Socket, it doesn't affect recv in any way.

        Huh! Good to know. Thank you zwon++

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://998612]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2015-07-03 16:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (54 votes), past polls