import socket # Create a socket sock = socket.socket(socket_family, socket_type) # Create a stream socket sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Socket family (here Adress Family veriosn 4 or IPv4) AF_INET # Socket type TCP connections SOCKET_STREAM # Socket type UDP connections SOCK_DGRAM # Translate a host name to IPv4 address format gethostbyname("host") # Translate a host name to IPv4 address format, extended interface socket.gethostbyname_ex("host") # Get the fqdn (fully qualified domain name) socket.getfqdn("8.8.8.8") # Returns the host name of the machine socket.gethostname() # Exception handling socket.error