i am hoping to use perl to verify whether a remote machine is listening on 
UDP/69. i've found some examples, and modified them slightly to come up 
with the attached snippet of code. the output always seems to be that the 
"port is up". i am imagining that $disconn is never being set to true 
since the $checkport will always at least attempt a connection.

maybe my reasoning to that is incorrect, but i guess, that is why i am 
writing :) any help is appreciated. thanks -charles


#!/usr/bin/perl -w

use strict;
use IO::Socket;

my $remoteip = "10.6.21.10";
my $port = "69";
my $proto = "udp";
 my $disconn = 0;
 my $checkport = IO::Socket::INET->new(
              PeerAddr => "$remoteip",
              PeerPort => "$port",
              Proto => "$proto",
              Timeout => '0') or $disconn = 1;

 if ($disconn) {
   print "  Port $port is down.\n";
 } else {
  print "  Port $port is up.\n";
 }
 close $checkport;



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to