socket.inet_ntoa()

socket.inet_ntoa(packed_ip) Convert a 32-bit packed IPv4 address (a bytes-like object four bytes in length) to its standard dotted-quad string representation (for example, ‘123.45.67.89’). This is useful when conversing with a program that uses the standard C library and needs objects of type struct in_addr, which is the C type for the 32-bit packed binary data this function takes as an argument. If the byte sequence passed to this function is not exactly 4 bytes in length, OSError will be r

socket.inet_aton()

socket.inet_aton(ip_string) Convert an IPv4 address from dotted-quad string format (for example, ‘123.45.67.89’) to 32-bit packed binary format, as a bytes object four characters in length. This is useful when conversing with a program that uses the standard C library and needs objects of type struct in_addr, which is the C type for the 32-bit packed binary this function returns. inet_aton() also accepts strings with less than three dots; see the Unix manual page inet(3) for details. If the

socket.if_nametoindex()

socket.if_nametoindex(if_name) Return a network interface index number corresponding to an interface name. OSError if no interface with the given name exists. Availability: Unix. New in version 3.3.

socket.if_nameindex()

socket.if_nameindex() Return a list of network interface information (index int, name string) tuples. OSError if the system call fails. Availability: Unix. New in version 3.3.

socket.if_indextoname()

socket.if_indextoname(if_index) Return a network interface name corresponding to an interface index number. OSError if no interface with the given index exists. Availability: Unix. New in version 3.3.

socket.htons()

socket.htons(x) Convert 16-bit positive integers from host to network byte order. On machines where the host byte order is the same as network byte order, this is a no-op; otherwise, it performs a 2-byte swap operation.

socket.htonl()

socket.htonl(x) Convert 32-bit positive integers from host to network byte order. On machines where the host byte order is the same as network byte order, this is a no-op; otherwise, it performs a 4-byte swap operation.

socket.herror

exception socket.herror A subclass of OSError, this exception is raised for address-related errors, i.e. for functions that use h_errno in the POSIX C API, including gethostbyname_ex() and gethostbyaddr(). The accompanying value is a pair (h_errno, string) representing an error returned by a library call. h_errno is a numeric value, while string represents the description of h_errno, as returned by the hstrerror() C function. Changed in version 3.3: This class was made a subclass of OSError

socket.has_ipv6

socket.has_ipv6 This constant contains a boolean value which indicates if IPv6 is supported on this platform.

socket.getservbyport()

socket.getservbyport(port[, protocolname]) Translate an Internet port number and protocol name to a service name for that service. The optional protocol name, if given, should be 'tcp' or 'udp', otherwise any protocol will match.