Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking for UDP availability

Status
Not open for further replies.

ourobolus

Technical User
Jul 5, 2006
1
US
I'm using a Garmin GPS system to stream data to my computer through a UDP stream. The script I have runs fine when the device is attached and enabled, but when it isn't, the script merely continuously checks for the UDP data rather than realizing that it isn't sending any data. If this were TCP, it would be simple enough to determine a connection, but...eh.

use IO::Socket::INET;
my $MySocket = IO::Socket::INET -> new(LocalPort=>3944, Proto=>'udp');

That's my current setup, but I'd like to figure out some form of error checking that would allow the program to run regardless of the UDP connection.

Thanks.
 
Not really sure if this fits your problem, but the general rule of the thumb is to use IO::Select or IO::poll with a timeout and then check the flags for errors, data, etc. Because of the timeout your programs runs (in a loop) regardless of anything.

HTH,
San

---
cheers!
san
smoking3vc.gif


print length "The answer to life, universe & everything!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top