You are not logged in.
Pages: 1
What would be the best method to handle a large number of sockets in c++ without them blocking the app?
Currently i use poll() in my program which works just fine but is limited to 1024 file descriptors.
From what i've read setting the socket to non blocking is somewhat cpu intensive when calling recv() all the time for a large number of them.
So what would be the suggested way to handle 3000+ connections in a single thread? or should i rather just forget about that idea? ^^
Offline
Does select() have the same limitation?
The suggestion box only accepts patches.
Offline
If I were you, I would use threads instead. Maybe Protothreads will do the job very good when using a big number of threads. Also, Erlang will perform very good under these circumstances (but require you to know the language first).
Furthermore: 3000+ connections? What ever you do, it doesn't sound healthy to me. And I'm in the development team of a peer-to-peer program...
Offline
Been poking around a bit with select() but so far didnt really get it to work the way i want, after some calls it will just stop returning (or only returns timeouts).
As for the 3000 connections, imagine something like an mmorpg server with 3000 people playing on it, thats what it is supposed to be.
I guess ill just use poll() and run each connection in its own thread, that should do the job somehow =P
Offline
Pages: 1