conversationoutside the standard protocol range here are the client' socket callssockobj socket(af_inetsock_streamcreates python socket object in the client programjust like the server sockobj connect((serverhostserverport)opens connection to the machine and port on which the server program is listening for client connections this is where the client specifies the string name of the service to be contacted in the clientwe can either specify the name of the remote machine as domain name ( starship python netor numeric ip address we can also give the server name as localhost (or the equivalent ip address to specify that the server program is running on the same machine as the clientthat comes in handy for debugging servers without having to connect to the net and againthe client' port number must match the server' exactly note the nested parentheses again--just as in server bind callswe really pass the server' host/port address to connect in tuple object once the client establishes connection to the serverit falls into loopsending message one line at time and printing whatever the server sends back after each line is sentsockobj send(linetransfers the next byte-string message line to the server over the socket notice that the default list of lines contains bytes strings ( 'just as on the serverdata passed through the socket must be byte stringthough it can be the result of manual str encode encoding call or an object conversion with pickle or struct if desired when lines to be sent are given as command-line arguments insteadthey must be converted from str to bytesthe client arranges this by encoding in generator expression ( call map(str encodesys argv[ :]would have the same effectdata sockobj recv( reads the next reply line sent by the server program technicallythis reads up to , bytes of the next reply message and returns it as byte string sockobj close(closes the connection with the serversending it the end-of-file signal and that' it the server exchanges one or more lines of text with each client that connects the operating system takes care of locating remote machinesrouting bytes sent between programs and possibly across the internetand (with tcpmaking sure that our messages arrive intact that involves lot of processingtoo--our strings may ultimately travel around the worldcrossing phone wiressatellite linksand more along the way but we can be happily ignorant of what goes on beneath the socket call layer when programming in python socket programming