The MASM Forum

Miscellaneous => The Orphanage => Topic started by: xanatose on February 14, 2014, 11:25:09 PM

Title: How do you wait for more than 64 sockets?
Post by: xanatose on February 14, 2014, 11:25:09 PM
Does any one knows an example for waiting for more than 64 sockets on a windows program.

If not, would dividing it into threads of a maximum of 64 sockets per thread work?

I basically need to implement a simple chat server with a maximum of around 1,000 users per machine with small packets with a maximum size of 1k. Besides ditching TCP and using UDP (which would bring its own set of troubles), what would be a good approach of doing this?
Title: Re: How do you wait for more than 64 sockets?
Post by: Tedd on February 15, 2014, 06:11:37 AM
Use UDP :biggrin:

select allows you to check the state of a set of up-to 64 sockets at a time..
Call select for sockets 0-63, then call again for sockets 64-127, then again for the next 64...

But I'd consider changing to use async sockets with WSAAsyncSelect instead - you're supplied with a message when a socket needs attention, so there's no need for you to check.