your program www py com socket connect send recv port web pages figure socket connection last-modifiedsat may : : gmt etag" - accept-rangesbytes content-length cache-controlmax-age= no-cacheno-storemust-revalidate pragmano-cache expireswed jan : : gmt connectionclose content-typetext/plain but soft what light through yonder window breaks it is the east and juliet is the sun arise fair sun and kill the envious moon who is already sick and pale with grief the output starts with headers which the web server sends to describe the document for examplethe content-type header indicates that the document is plain text document (text/plainafter the server sends us the headersit adds blank line to indicate the end of the headersand then sends the actual data of the file romeo txt this example shows how to make low-level network connection with sockets sockets can be used to communicate with web server or with mail server or many other kinds of servers all that is needed is to find the document which describes the protocol and write the code to send and receive the data according to the protocol howeversince the protocol that we use most commonly is the http web protocolpython has special library specifically designed to support the http protocol for the retrieval of documents and data over the web one of the requirements for using the http protocol is the need to send and receive data as bytes objectsinstead of strings in the preceding examplethe encode(and decode(methods convert strings into bytes objects and back again the next example uses 'notation to specify that variable should be stored as bytes object encode(and 'are equivalent