multithreading - Connect and handle multiple raw sockets at once in Python 2.x -


i new python, , trying learn "on job". , required this.

i required communicate 3 servers raw socket connection. can in sequential manner. wondering if there way can communicate these 3 servers @ once? 3 servers have different ip addresses.

basically try following in 1 step:

s = socket.socket(socket.af_inet, socket.sock_stream) s.connect((host1, port1)) s.connect((host2, port1)) s.connect((host3, port1)) 

which need later s.sendall() & s.recv() parallelized.

if have 1 listening thread, can use select wait on multiple sockets , woken when of them return data:

https://docs.python.org/2/library/select.html


Comments