socket.getservbyname(servicename, protocolname)
- This function translates an internet service name and protocol name to a port number
- The
servicename
represents the service name (e.g. ftp) - The
protocolname
represents tbe protocol name (e.g. tcp) - The
protocolname
should betcp
orudp
Example of getservbyname
>>> import socket
>>> socket.getservbyname('ftp', 'tcp')
21
References
Previous
Next