Hi,<br><br>I would like to have a client connect via TCP to a server (say, server &quot;A&quot;), then the client close the connection and connect via TCP to another server (say, server &quot;B&quot;) using the same TCP port that was bound locally while connecting to &quot;A&quot;. And then this done over and over again switching from B to A to B etc..<br>
<br>The fact is that it all works if both the client and the server do transport.loseConnection() before the client tries to connect to the other server from the same local port, instead if *only* the client does transport.loseConnection(), I obtain:<br>
<br><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">[Failure instance: Traceback (failure with no frames): &lt;class &#39;twisted.internet.error.ConnectBindError&#39;&gt;: Couldn&#39;t bind: 98: Address already in use.</blockquote>
<div><br>which it is strange to me as the next connectTCP() attempt is called in the connectionLost() method of the client, so the socket should be closed already. <br></div><div><br>For the very generous readers, I post at <a href="http://pastebin.com/m31b0d911">http://pastebin.com/m31b0d911</a> the code which can be just executed in this way:<br>
<br>* on a terminal, for the server:&nbsp; python tcp_listen_connect.py -server<br><br>* on another terminal, for the client:&nbsp; python tcp_listen_connect.py -client 127.0.0.1<br></div><br>Comment/uncomment line number 21 to see the affected behaviour.<br>
<br>Sorry for the &quot;please download and verify&quot; approach, but it&#39;s 2 days I&#39;m struggling with it and I was wondering if there is really something I&#39;m doing wrong or it&#39;s just that it works like that.<br>
<br>Thanks in advance. <br>Regards,<br>Alessio Pace.<br>