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
port
represents the port number (e.g. 21) - The
protocolname
represents tbe protocol name (e.g. tcp) - The
protocolname
should betcp
orudp
Example of getservbyport
>>> import socket
>>> socket.getservbyport(21, 'tcp')
'ftp'
References
Previous
Next