I'm trying to test out the success or failure of sending a UDP message to a set of servers which may be up or down.
On the port range I have chosen, the response seems to alternate and not be the same each time, I have waded back and forth through the perldoc and the cookbook for a clue, to no avail, so is it a problem with my use of the IO modules?
I am getting:
READ *3*
READ *0*
Read IO select timed out at ./socket.pl line 24.
READ *3*
READ *0*
Read IO select timed out at ./socket.pl line 24
when instead I want four dies in a row....
code below:
#!/usr/local/bin/perl -w
use strict;
use IO::Select;
use IO::Socket;
my $server = '127.0.0.1';
for (8721 .. 8724) {
my $fd = new IO::Socket::INET( PeerAddr => $server,
PeerPort => $_,
Proto => 'udp');
my $sockin = new IO::Select( $fd );
eval {
$fd->send( 'Test string' );
my $read = IO::Select->select( $sockin, undef, undef, 3);
print "READ *$read*\n";
die "IO select timed out" unless $read;
};
print "Read $@" if $@;
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.