title: How to avoid [Errno 98] Address already in use
body: <p>HTTP is stateless connection. I am making 'HTTP Server'(I am very new to programming).</p>
  
  <p>What I want to do is use POST methods to exchange information between browser and python based http server. To make it work I must close socket and open it up again(because of HTTP specification, I understand connection must be completely closed before you can make new connection to server to use GET or POST method, again, I am planning to send big files over POST only, as GET is very limited)</p>
  
  <p>There is mechanism that prevents me to close/open socket using loop. I am not sure if its part of Unix sockets or Python specification. Probably former case.</p>
  
  <p>If I set socket.close()/socket.receive() loop - I get error:
  OSError: [Errno 98] Address already in use
  How do I solve my dilemma. Apache does this exactly no problem(I understand its in C or C++), but its probably using same sockets library on Unix anyway.(AFAIK python sockets is a wrapper for C or C++ library)</p>
  
  <p>I don't like idea of http.server, because it does not allow for post without 'CGI', which I don't think I need. Also it's pretty badly documented in my opinion.</p>
  
  <p>Tried reading http.server documentation.
  Tried to rebind port number of POST method, turned out - not really possible.
  Done several hours of googling.</p>
  
  <pre><code>while None is None:
      connection, addr = server.accept()
      content_of_connection = connection.recv(1024)
      connection.sendall(some_words.encode())
      connection.sendall(content_of_connection)
      print (content_of_connection.decode())
      server.close()
  </code></pre>
  
  <p>Need to make looping of 'socket.close()' not give error "OSError: [Errno 98] Address already in use".</p>