Mega Code Archive

 
Categories / Perl / Network
 

The getservbyport function retrieves information from the etcservices file

# Format: getservbyport(PORT, PROTOCOL); #!/bin/perl print "What is the port number? "; chomp($PORT=<>); print "What is the protocol? "; chomp($PROTOCOL=<>); ($name, $aliases, $port, $proto ) = getservbyport($PORT, $PROTOCOL); print "The getservbyport function returns:         name=$name         aliases=$aliases         port number=$port         prototype=$protocol \n";