programming-examples/perl/Network/The getservbyport function retrieves information from the _etc_services file.pl

15 lines
389 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
# 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";