service name package

M

Me

How can I get a service name using IANA assigned port numbers?
I want pass a port number and possibly the protocol (tcp,udp,etc)
and have the name returned.

One package that does this but I can't get to install via CPAN
is Net::IANA::portNumbers.
 
T

Ted Zlatanov

How can I get a service name using IANA assigned port numbers?
I want pass a port number and possibly the protocol (tcp,udp,etc)
and have the name returned.

One package that does this but I can't get to install via CPAN
is Net::IANA::portNumbers.

Have look at "perldoc -f getservbyport".

my @data = getservbyport( 21, 'tcp' );
print "Service is: " . $data[0] if( @data );

Great answer, only one thing: this uses the machine's local
definitions of services (usually from /etc/services in a Unix
environment AFAIK). So if the OP wants the real IANA numbers, not the
ones defined by this particular system (and yes, they should be the
same) then they have to use the CPAN module mentioned above.

Ted
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,250
Latest member
Charlesreero

Latest Threads

Top