You are not logged in.

#1 2008-11-27 19:43:58

Envil
Member
Registered: 2008-11-18
Posts: 52

c++ sockets

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

#2 2008-11-27 20:21:45

neotuli
Lazy Developer
From: London, UK
Registered: 2004-07-06
Posts: 1,204
Website

Re: c++ sockets

Does select() have the same limitation?


The suggestion box only accepts patches.

Offline

#3 2008-11-27 20:22:22

wuischke
Member
From: Suisse Romande
Registered: 2007-01-06
Posts: 630

Re: c++ sockets

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

#4 2008-11-28 17:57:20

Envil
Member
Registered: 2008-11-18
Posts: 52

Re: c++ sockets

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

Board footer

Powered by FluxBB