Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Anyways here is a copy paste of the udp client(the tcp client works fine BTW)
I'd appreciate anything you have to say on this thanks,sub UDPing { $remote = IO::Socket::INET->new( Proto => "$type", PeerAddr => "$server", PeerPort => "$port" ) or die "Couldn't connect $type Socket:\n$!"; $peeraddr = join "." => unpack "C*" => $remote->peeraddr(); $select = IO::Select->new($remote); while ($count <= $magic) { $start = Time::HiRes::time; if ($count < 2) { print("${type}ing $server ($peeraddr):\n"); } $remote->send('PING'); if ($select->can_read(3)) { $rtt = 1000 * (Time::HiRes::time - $start); $r = $remote->recv($data, 0); printf("$peeraddr: ${type}_no=$count time=%.3f ms\n", $rtt); UpdateStats($rtt); } else { print ("Request Timed Out.\n"); UpdateStats(); } $count++; } }
Chris
Edit by dws to add <code> tags
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: IO::Socket and windows
by Zaxo (Archbishop) on Jan 12, 2003 at 12:16 UTC |