Jon Davis wrote:
Assuming I stay clear of CLR / managed code as this is intended to be
optimized for speed as a Windows service, what is the best and
easiest API for TCP and UDP network programming? I've been told I
should stay away from MFC's CSocket because it's profoundly buggy...
or something. Target deployment environments are Win2000, WinXP,
Win2003, and WinVista.
Frankly, your best bet would be to use .NET 2.0. It wraps up a very
sophisticated async socket model using IO Completion ports that's a lot of
work to reproduce. Real-world experience has shown that it's possible to
scale a .NET sockets app to support 1,000,000 simultaneous users on a single
machine (granted, a 16-way Itanium with tons of memory, but still...).
Don't make the mistake of dismissing a CLR-based solution because "it will
be too slow", because very likely it wouldn't be.
That said, you'll get the best performance by mimicing what .NET does - use
async reads and writes and IO completion ports. You can get at all of that
through the Win32 API. I'm sure there are some high-quality IOCP-based
sockets libraries for Windows "out there" as well - I'd suggest letting
Google do your walking for a bit and see what you can turn up. If nothing
else, you can do as programmers have done for decades and reinvent the
wheel yourself.
-cd