specify the sequence of control messages exchanged during conversations by defining regular patterns of communicationprotocols make communication more robust they can also minimize deadlock conditions--machines waiting for messages that never arrive for examplethe ftp protocol prevents deadlock by conversing over two socketsone for control messages only and one to transfer file data an ftp server listens for control messages ( "send me file"on one portand transfers file data over another ftp clients open socket connections to the server machine' control portsend requestsand send or receive file data over socket connected to data port on the server machine ftp also defines standard message structures passed between client and server the control message used to request filefor instancemust follow standard format python' internet library modules if all of this sounds horribly complexcheer uppython' standard protocol modules handle all the details for examplethe python library' ftplib module manages all the socket and message-level handshaking implied by the ftp protocol scripts that import ftplib have access to much higher-level interface for ftping files and can be largely ignorant of both the underlying ftp protocol and the sockets over which it runs +in facteach supported protocol is represented in python' standard library by either module package of the same name as the protocol or by module file with name of the form xxxlib pywhere xxx is replaced by the protocol' name the last column in table - gives the module name for some standard protocol modules for instanceftp is supported by the module file ftplib py and http by package http moreoverwithin the protocol modulesthe top-level interface object is often the name of the protocol sofor instanceto start an ftp session in python scriptyou run import ftplib and pass appropriate parameters in call to ftplib ftpfor telnetcreate telnetlib telnet instance in addition to the protocol implementation modules in table - python' standard library also contains modules for fetching replies from web servers for web page request (urllib request)parsing and handling data once it has been transferred over sockets or protocols (html parserthe email and xml packages)and more table - lists some of the more commonly used modules in this category +since python is an open source systemyou can read the source code of the ftplib module if you are curious about how the underlying protocol actually works see the ftplib py file in the standard source library directory in your machine its code is complex (since it must format messages and manage two sockets)but with the other standard internet protocol modulesit is good example of low-level socket programming plumbing the internet