socket.getservbyport

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

Example of getservbyport

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

References

Previous
Next

socket.getservbyname

socket.accept