in reply to Many sockets under one select

If you are adventurous enough, you could try threads, but using them is "officially discouraged" (though not (yet) deprecated).

Lowering the read size, while very simple, will significantly degrade performance.

Non-blocking writes will add a lot of complexity. I think you will have to select on writability as well as readability.

If there is known maximum number of clients, you could pre-fork "worker" processes. Your "master" process would listen for connect requests, then "hand" them off to the next available worker. Unfortuantely, it has been many years since I did something like that, so I don't remember how to do the "hand off".

Unless there are performance or resource reasons to not use the fork-on-demand model, is probably best to just stay with that.

Replies are listed 'Best First'.
Re^2: Many sockets under one select
by linxdev (Sexton) on Oct 29, 2014 at 20:10 UTC
    I had thought the same. I was just looking at possible solutions to make the single thread idea work. Thanks.