Python Print Socket used to connect to server
<p>What I am trying to do is a little bit complicated to explain but hopefuly this explanation makes sense and someone will be able to help</p>

<p>I have a python socket client and server. Everything works fine, and for development purposes I have made the server also print a message when a new client connects. I have noticed the server will output something like:</p>

<pre><code>New connection on 127.0.0.1:26386
</code></pre>

<p>The  server runs on port 8888. Anyway, I noticed that the client port is different for every client.</p>

<pre><code>New connection on 127.0.0.1:26397
New connection on 127.0.0.1:26398
</code></pre>

<p>And so on. What I would like is very simple: I want the client to print the port its using to connect to the server. So client 1 would print 26386 as seen above. The next one 26397 and 26398 and so on.</p>

<p>How can I do this? I understand the explanation might be a bit weird, just comment if you want me to clarify anything.</p>

<p>Thanks</p>