Checking for an open port : getservbyport « Network « Perl






Checking for an open port

    

#!/usr/bin/perl -w

# Finds an open port.
$port = 2345;
while (getservbyport($port, "tcp") ) {
    $port++;
}
print "An open port number is $port\n";

   
    
    
    
  








Related examples in the same category

1.The getservbyport function retrieves information from the /etc/services file.