I have a quite simple problem here. I need to communicate with a lot of hosts simultaneously, but I do not really need any synchronization because each request is pretty self sufficient.
Because of that, I chose to work with asynchronous sockets, rather than spamming threads.
Now I do have a little problem:
The async stuff works like a charm, but when I connect to 100 hosts, and I get 100 timeouts (timeout = 10 secs) then I wait 1000 seconds, just to find out all my connections failed.
Is there any way to also get non blocking socket connects?
My socket is already set to nonBlocking, but calls to connect() are still blocking.
Reducing the timeout is not an acceptable solution.
I am doing this in Python, but I guess the programming language doesnt really matter in this case.
Do I really need to use threads?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…