socket.getservbyname

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 be tcp or udp

Example of getservbyname

>>> import socket
>>> socket.getservbyname('ftp', 'tcp')
21

References

Previous
Next

socket.gethostbyaddr

socket.getservbyport