Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

I am running a server which just basically echos(port 7) whatever you send it on whatever port it listens on. Now that end runs fine however the client I have works great on win98/XP and won't work on win2kPro(haven't tried NT4.0). Any reasons as to why? I am using ActiveState Perl but I figure perl is perl and unless active state OR the winsock in the NT architecture is different then it should work right?

Anyways here is a copy paste of the udp client(the tcp client works fine BTW)

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++; } }
I'd appreciate anything you have to say on this thanks,

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

    Your sub UDPing is either a closure or accesses lots of global variables. Can't tell which without more code. It appears likely that $remote is global - my $remote = IO::Socket::INET->new(... will restrict its scope.

    Add

    use diagnostics; use strict;
    at the top to get useful messages about what else may be wrong.

    Many recent ms platforms have echo service turned off because of security problems in their implementation. Icmp ping is the usual victim, but other protocols may also be afflicted. Your sub issues die if it fails to connect.

    After Compline,
    Zaxo