title: Explain http keep-alive mechanism
body: <blockquote>
    <p>Keep-alives were added to HTTP to basically reduce the significant
    overhead of rapidly creating and closing socket connections for each
    new request. The following is a summary of how it works within HTTP
    1.0 and 1.1:</p>
    
    <p>HTTP 1.0    The HTTP 1.0 specification does not really delve into how
    Keep-Alive should work. Basically, browsers that support Keep-Alive
    appended an additional header to the request as [edited for clarity] explained below:</p>
    
    <p>When the server processes the request and
    generates a response, it also adds a header to the response:</p>
    
    <p><strong>Connection: Keep-Alive</strong>  </p>
    
    <p>When this is done, the socket connection is
    not closed as before, but kept open after sending the response. When
    the client sends another request, it reuses the same connection. The
    connection will continue to be reused until either the client or
    the server decides that the conversation is over, and one of them drops the connection.</p>
  </blockquote>
  
  <p>The above explanation <a href="http://www.jguru.com/faq/view.jsp?EID=704228" rel="noreferrer">comes from here</a>. But I don't understand one thing </p>
  
  <blockquote>
    <p>When this is done, the socket connection is not closed as before, but
    kept open after sending the response.</p>
  </blockquote>
  
  <p>As I understand we just send tcp packets to make requests and responses, how this <code>socket connection</code> helps and how does it work? We still have to send packets, but how can it somehow establish the persistent connection? It seems so unreal.</p>