socket.getservbyport(port, protocolname)
- This function translates a port number and protocol name to an internet service name
- This is the opposite of
getservbyname - The
portrepresents the port number (e.g. 21) - The
protocolnamerepresents tbe protocol name (e.g. tcp) - The
protocolnameshould betcporudp
Example of getservbyport
>>> import socket
>>> socket.getservbyport(21, 'tcp')
'ftp'References
Previous
Next