in reply to UDP connection
You want to do something like the following (untested pseudo code):
There's a much simpler solution though, and that may work for you:... create sockets ... my @fileno = (fileno(SOCKET1), fileno(SOCKET2), fileno(SOCKET3), fileno(SOCKET4)); my ($rbits, $ebits); vec($rbits, $_, 1) = 1 for @fileno; vec($ebits, $_, 1) = 1 for @fileno; while (1) { my $time_to_next_heartbeat = ...; # How long till we have to send + a hb if ($time_to_next_heartbeat <= 0) { ... send heartbeats ... redo; } if (select (my $rbits = $rbits, undef, my $ebits = $ebits, $time_t +o_next_heartbeat)) { if ($ebits) { ... deal with errors ... } if ($rbits) { foreach my $fileno (@fileno) { if (vec($rbits, $filen0, 1)) { ... read data ... } } } } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: UDP connection
by BrowserUk (Patriarch) on May 03, 2012 at 14:02 UTC | |
by JavaFan (Canon) on May 03, 2012 at 14:45 UTC | |
by BrowserUk (Patriarch) on May 03, 2012 at 19:52 UTC | |
by JavaFan (Canon) on May 03, 2012 at 21:26 UTC | |
by BrowserUk (Patriarch) on May 03, 2012 at 22:26 UTC | |
|