Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^3: UDP Client Multiple servers

by zwon (Abbot)
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"; } }

Replies are listed 'Best First'.
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?
[Eily]: and Hilarity Ensues
Eily says, while failing to write a link properly
[Your Mother]: Goodbye Fancy Feast! Hello Friskies!!!
[LanX]: CB sidebar auto-expansion problem
[Eily]: "tail: warning: following standard input indefinitely is ineffective". I can't help but feel that tail is judging me...
[Your Mother]: Someone had to say it. Better it came from tail.
[LanX]: Cat Mama!
[Your Mother]: Das right.
[Eily]: actually I forgot to provide the filename as a parameter
LanX it reeks.

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (9)
As of 2017-03-27 16:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (320 votes). Check out past polls.