network programming and sockets value is four-character string containing the binary encoding this may be useful if passing the address to or if the address must be packed into data structure passed to other programs does not support ipv inet_ntoa(packedipconverts binary-packaged ipv address into string that uses the standard dotted representation (for example 'packedip is four-character string containing the raw -bit encoding of an ip address the function may be useful if an address has been received from or is being unpacked from data structure it does not support ipv inet_ntop(address_familypacked_ipconverts packed binary string packed_ip representing an ip network address into string such as address_family is the address family and is usually af_inet or af_inet this can be used to obtain network address string from buffer of raw bytes (for instancefrom the contents of low-level network packetinet_pton(address_familyip_stringconverts an ip address such as into packed byte string address_family is the address family and is usually af_inet or af_inet this can be used if you're trying to encode network address into raw binary data packet ntohl(xconverts -bit integers from network (big-endianto host byte order ntohs(xconverts -bit integers from network (big-endianto host byte order setdefaulttimeout(timeoutsets the default timeout for newly created socket objects timeout is floating-point number specified in seconds value of none may be supplied to indicate no timeout (this is the defaultsocket(familytype [proto]creates new socket using the given address familysocket typeand protocol number family is the address family and type is the socket type as discussed in the first part of this section to open tcp connectionuse socket(af_inetsock_streamto open udp connectionuse socket(af_inetsock_dgramthe function returns an instance of sockettype (described shortlythe protocol number is usually omitted (and defaults to this is typically only used with raw sockets (sock_rawand is set to constant that depends on the address family being used the following list shows all of the protocol numbers that python may define for af_inet and af_inet depending on their availability on the host systemconstant description ipproto_ah ipproto_bip ipproto_dstopts ipproto_egp ipv authentication header banyan vines ipv destination options exterior gateway protocol lib fl ff