Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here is an answer to a similar looking question that I prepared earlier.... much earlier... <a href="https://stackoverflow.com/a/1436261/21945">Socket in use error when reusing sockets</a> </p> <p>The error is different, but the underlying problem is probably the same: you are consuming all available ports and trying to reuse them before the TIME_WAIT state has ended.</p> <p><strong>[EDIT: in response to comments]</strong></p> <p>If it is within the capability/spec for your application, one obvious strategy is to control the rate of connections to avoid this situation.</p> <p>Alternatively, you could use the <a href="http://docs.python.org/library/httplib.html#module-httplib" rel="nofollow noreferrer"><code>httplib</code></a> module. <code>httplib.HTTPConnection()</code> lets you specify a <code>source_address</code> tuple with which you can specify the port from which to make the connection, e.g. this will connect to localhost:1234 from localhost:9999:</p> <pre><code>import httplib conn = httplib.HTTPConnection('localhost:1234', source_address=('localhost',9999)) conn.request('GET', '/index.html') </code></pre> <p>Then it is a matter of managing the source port assignment as described in my earlier answer. If you are on Windows you can use this method to get around the default range of ports 1024-5000.</p> <p>There is (of course), an upper limit to how many connections you are going to be able to make and it is questionable what sort of an application would require making thousands of connections in rapid succession.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload