title: How to force OS to free port with python
body: <p><br>
  I use a port in my python program and close it,now I want to use it again.Just that port not another port.
  <br>
  Is there any way to force OS to free port with python?</p>
  
  <pre><code>#!/usr/bin/python           # This is server.py file 
  
  import socket               # Import socket module
  
  s = socket.socket()         # Create a socket object
  host = socket.gethostname() # Get local machine name
  port = 12349
  portt = 12341               # Reserve a port for your service.
  
  s.bind((host, portt))        # Bind to the port
  
  s.connect((host, port))
  s.close
  
  ss = socket.socket()         # Create a socket object
  host = socket.gethostname() # Get local machine name 
  ss.bind((host, portt))
  
  s.close
  </code></pre>
  
  <p>but the output is:</p>
  
  <pre><code>Traceback (most recent call last):
    File "client.py", line 17, in &lt;module&gt;
      ss.bind((host, portt))
    File "/usr/lib/python2.7/socket.py", line 224, in meth
      return getattr(self._sock,name)(*args)
  socket.error: [Errno 98] Address already in use
  </code></pre>