🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Winsock v1.1 or v2

Started by
3 comments, last by BoRReL 22 years, 8 months ago
Heya, What is the difference between those two? Is the extra stuff coming with V2 useful for game programming? I''m trying to set up a non-blocking client-server based model. Thanks in advance!! Gr, BoRReL
Advertisement
Not really, you can do everything in 1.1 that you could in 2.0, but I believe that 2.0 makes non-blocking stuff more windows-friendly (i.e. you can have it post messages when data arrives, as opposed to using select() or whatever.)

Still, if you''re thinking about using 2.0 (which isn''t very cross-platform) then I think you should consider I/O Completion Ports, which you can use with 1.1 sockets - it''s also not very cross-platform, but it''s insanely scalable (100,000 simultaneous clients is not unheard of), and insanely fast.

codeka.com - Just click it.
Thanks!!

What are those I/O completion ports?? I''ve seen the name a lot, but don''t have a clue what they mean.

Gr,
BoRReL
The basic idea behind I/O completion ports as far as I understand it is the following:

In a classic server setup, you''ve got loads of ports, and to check which one has data waiting you call select() or poll() with an fdset of sockets you want to wait on.
The problem with this approach is that it doesn''t scale really well because you have to walk the array of sockets again and again.

With I/O completion ports, however, you''ve got only a single socket or pipe or whatever to wait on. Everytime a packet arrives for your application, the kernel writes a small data structure with the socket # and additional information to that pipe.

The WinNT implementation of IOCP has some additional features like automatic thread pool management, and it can be used for more than sockets (e.g. you can use it for file access as well). I don''t know the implementation details for WinNT, so my description might be a little off, but it''s the basic idea that counts

Unfortunately, IOCP is neither supported on Win9x nor on Linux (though work is in progress).

cu,
Prefect

One line of sourcecode says more than a thousand words.
Widelands - laid back, free software strategy
If you have the platform SDK, there''s a great example in the Samples\NetDS\WinSock\Pop3 directory (don''t bother with the Samples\NetDS\WinSock\iocp sample, it''s not as good )

Yeah, it''s only supported on Windows NT (and 2000 and XP) but if you''re making a server, you''d be pretty crazy to try and run it on a 9X machine anyway. Also, while it''s not portable (directly) to Linux or whatever, it''s quite simple (usually) to abstract it out for porting.

codeka.com - Just click it.

This topic is closed to new replies.

Advertisement