Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
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 making s'mores by the fire in the courtyard of the Monastery: (10)
As of 2014-12-25 05:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (159 votes), past polls