Advertisement

IOCP == many connections?

Started by February 02, 2006 01:13 PM
5 comments, last by Afr0m@n 19 years ago
Ok can someone please get this straight for me; Do you need IOCP in WinSock (I'm using TCP atm) to accept thousands of connections, or can you get by with standard async sockets? If you can get by with standard async sockets, what are really the benefit of IOCP sockets then?
_______________________Afr0Games
I'm fairly certain windows has a fairly low socket limit. To accept thousands of connections simultaneously is not possible with WinSock on OS's with the low socket limit.

I'd seriously think about using some easily portable code (berkeley sockets) if I had a requirement like that. ;-) I'd also probably use a reliable UDP layer rather than a socket per connection with that kind of load.

Winterdyne Solutions Ltd is recruiting - this thread for details!
Advertisement
The Forum FAQ kills the myth about the "64-socket limit". You can easily get past that limit for a single call to select(). In fact, if your version of Windows allows you to create a thousand sockets, a call to select() MAY be sufficient to service them all, although it won't be quite as efficient as IOCP.

The original poster talked about async sockets, which is an API where Windows will send a Windows Message to your window for each event on each socket. This API has been known to scale really poorly; I'd doubt you could actually get anywhere close to 1000 sockets using that system. Google seems to claim you can't go beyond 63 sockets in WSAAsyncSelect(), and that limit is not changeable (as opposed to the select() limit).
enum Bool { True, False, FileNotFound };
Regardless of what the limits actually are, it should be pointed out that you can in principle, have more clients by sharing them between multiple threads or processes on one server.

For example, if you can take 100 clients comfortably each, there could be one process for each zone with 100 clients or something.

What appears to cause major problems is trying to (ab)use user32 window messaging for large numbers of clients. Although it works with large numbers of sockets (over 400), there are some serious scalability problems.

Unlike select(), they aren't in the user-mode code, but somewhere inside Windows. I guess this will probably not be fixed, as it's not a use-case that anyone cares about (or indeed, should).

In my opinion, using user32 as a socket message notification system is just daft - it forces your non-GUI, server application to link with user32 and create a window for no reason, and it doesn't make any sense. WSAAsyncSelect was designed for win16 where you had no preemptive multitasking or threads, therefore select() was not an option.

Mark
Thanks guys! For now, I think I'll go with IOCP for two reasons:

1. Using IOCP will enable me to handle thousands of clients without having to change anything, and it's a fact, as opposed to using select which involves alot of "but-s" "may-s" and whatnot.

2. Learning IOCP will be beneficial to my career as a network programmer someday. :)
_______________________Afr0Games

This topic is closed to new replies.

Advertisement