on port 8888 Now on http://localhost:8888/hello, “Hello, World!” will be displayed in your browser. This web address http://localhost:8088/hello is called your URL. It contains your HTTP Protocol, your host name localhost, your port number 8088, and your path leading you to the text, hello. Your browser finds this address of the web server to connect to, and the path of the page on the server to retrieve. It establishes a TCP connection with the web server USING SOCKETS, to send an HTTP request over the TCP connection to the server, then wait for the server to send a response back, and then displays the page. To create a TCP connection using sockets, we create a socket to bind to the port, then we allow the socket to listen for any responses and accept data, in order to finally establish a connection. An example of an HTTP Request is GET /hello HTTP/1.1, where GET is the HTTP method which as asking the server to return data , /hello is the path, and HTTP/1.1 is the HTTP version. An example of an HTP Response you might receive is HTTP/1.1 200 OK , along with the page information to be displayed after a line break, also known as the response body. 200 OK is the status response code. WORKING OF SOCKET: When you click on a link, your browser creates a socket to connect to the web server on a particular port. Basically your socket will contain the port and IP address where it will act as an end-point for a network connection on a machine. When the socket connection is complete, the socket can now send in a request for the text of the page. The same socket will read the reply, and then be destroyed, as client sockets are normally only used for one exchange, or small set of sequential exchanges. In a web server, it first creates a server socket to bind to the host port. Now we must allow the socket to listen. This tells the socket library to queue up the maximum number of connect (usually 5) requests before refusing outside connections. Now we have a server socket up and running. Now we can handle and produce client socket(s). Now these sockets can communicate through the channel established at the port, which will be recycled when the channel is destroyed. Now we can use various commands for communication between sockets, such as 'send' or 'recv.' However, send and recv handle network buffers more than bytes. That is, they return whatever the have received, or emptied, and the number of bytes they handled. Using a while loop, you can call the socket again and again to recv or send information until your data has been completely handled. This is how you can handle payloads. You can also specify the number of bytes you wish to end or receive at a time, when you call the socket to perform an action. If you have created your own client and server programs you may program your server code in such a way that it receives buffered information and receives the amount of data to be read, such that it reads all the data by breaking it up and reading it over a period of time. However, if you have created both your server and client application programs, the following methods can help you retrieve data efficiently: def mysend(self, msg): totalsent = 0 while totalsent < MSGLEN: sent = self.sock.send(msg[totalsent:]) if sent == 0: raise RuntimeError("socket connection broken") totalsent = totalsent + sent def myreceive(self): chunks = [] bytes_recd = 0 while bytes_recd < MSGLEN: chunk = self.sock.recv(min(MSGLEN - bytes_recd, 2048)) if chunk == '': raise RuntimeError("socket connection broken") chunks.append(chunk) bytes_recd = bytes_recd + len(chunk) return ''.join(chunks) On determining the message format type, and the length, you can use a loop to retrieve all of the data. If you decide to go the delimited route, you’ll be receiving in some arbitrary chunk size, (4096 or 8192 is frequently a good match for network buffer sizes), and scanning what you’ve received for a delimiter. In any case, use 2 loops to first determine the length and then get the data, as not all the data is sent or received in one pass.