Connect and handle multiple raw sockets at once in Python 2.x
<p>I am new to Python, and trying to learn it "on the job". And I am required to do this.</p>

<p>I am required to communicate with 3 servers with a raw socket connection. I can easily do that in a sequential manner. But I was wondering if there is a way I can communicate with these 3 servers at once? All 3 servers have different IP addresses. </p>

<p>Basically try to do the following but in 1 step:</p>

<pre><code>s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST1, PORT1))
s.connect((HOST2, PORT1))
s.connect((HOST3, PORT1))
</code></pre>

<p>which is also need later <code>s.sendall()</code> &amp; <code>s.recv()</code> to be parallelized. </p>

<p>If you only have one listening thread, you can use select to wait on multiple sockets and get woken when any of them return data:</p>

<p><a href="https://docs.python.org/2/library/select.html" rel="nofollow">https://docs.python.org/2/library/select.html</a></p>

python multithreading sockets multiprocessing raw-sockets