granted using combination of the host address and the port the following steps help illustrate how ports work with the host address to provide server access open python shell window you see the familiar python prompt type import socket and press enter remember that socket provides both host address and port information you use the socket to create connection that includes both items type socket getaddrinfo("localhost" and press enter the first value is the name of host you want to obtain information about the second value is the port on that host in this caseyou obtain the information about localhost port you see the output shown in figure - the output consists of two tuplesone for the internet protocol version (ipv output and one for the internet protocol version (ipv address each of these tuples contains five entriesfour of which you really don' need to worry about because you'll likely never need them howeverthe last entry( ' )shows the address and port for localhost port figure - the local host host provides both an ipv and an ipv address type socket getaddrinfo("johnmuellerbooks com" and press enter figure - shows the output from this command notice that this internet location provides only an ipv addressnot an ipv addressfor port the socket getaddrinfo(method provides useful method for determining how you can access particular location using ipv provides significant benefits over ipv (see networkcomputing com/networking/six-benefits-of-ipv / -id/ for details)but most internet locations provide only ipv support now