Python store client address?
<p>Below is my simple server code.</p>

<p>I want to store/print the addresses of any client's sending data.</p>

<p>For example the output should be:</p>

<pre><code>Connection from ('127.0.0.1', 61334)

foo from ('127.0.0.1', 61334)

Connection from ('127.0.0.1', 61335)

bar from ('127.0.0.1', 61335)

baz from ('127.0.0.1', 61334)

qux from ('127.0.0.1', 61335)
</code></pre>

<p>Someone told me to use dict but I don't know how?</p>

<pre><code>import select
import socket

server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server_socket.bind(('', 8888))
server_socket.listen(5)
print "Listening on port 8888"

read_list = [server_socket]
while True:
    readable, writable, errored = select.select(read_list, [], [])
    for s in readable:
        if s is server_socket:
            client_socket, address = server_socket.accept()
            read_list.append(client_socket)
            print "Connection from", address
        else:
            data = s.recv(1024)
            if data:
                s.send(data)
            else:
                s.close()
                read_list.remove(s)
</code></pre>
