0.1 - The Original Introduction

This FAQ was derived from the Winsock FAQ by Mark Towfiq. That FAQ’s introduction:

This FAQ has been put together by Mark Towfiq, with much-appreciated assistance from Jay Allard, Bruce Backman, Paul Brooks, Martin Hall, Simon Hewison, Mike Morse, Bob Quinn, Ed Schwalenberg, Bill Tang, Dave Treadwell, and Fred Whiteside.

0.2 - About the Maintainer

This FAQ’s current maintainer is Warren Young, who has been maintaining and extending this FAQ since 1997. He wrote his first networked program on DOS in 1993, and currently writes mostly for Linux and OS X.

0.3 - Legal Stuff

These pages are copyrighted. You may copy these pages to your local hard disk to read them off-line. All other rights are reserved by the author.


0.4 - Mirrors

There are no official mirrors of this site. For the latest, official FAQ, go to http://tangentsoft.net/wskfaq/.

0.5 - Where can I ask questions not already in the FAQ?

These days, the best place I know of to ask Winsock questions is Stack Overflow. I monitor the winsock tag with my RSS feed reader, so I may even answer your question. If not, you will likely get a good, rapid answer from someone else.

The MSDN Library contains reference documentation, tutorials, and even entire books covering all of Microsoft’s APIs, including Winsock. In recent years, they’ve made it public and web-searchable, so there’s no excuse not to take advantage of it. It’s a huge library of good stuff.

In the old days, the best place to ask was on mailing lists and Usenet newsgroups that are now dead. Much of what we discussed back then is still useful. You may be able to dig up information from such sources via Google Groups. If that doesn’t turn up anything useful, try your web search engine of choice. You might find something in a web archive of one of the old mail lists. Search engines also turn up newer information on sites like Stack Overflow.

I ignore most questions sent to me via email, because it goes totally against the idea of a FAQ. If I reply with the answer, only one person benefits. If I put the same amount of effort into adding that info to the FAQ, everyone who reads the FAQ benefits. If I haven’t yet decided to answer your question in the FAQ, it’s probably a rare enough or complex enough question that asking me to answer it amounts to asking for free, private consulting services. My generosity does not extend that far.

0.6 - Is there a mailing list for FAQ updates?

No, not at this time.

0.7 - What Windows and Winsock versions does the FAQ cover?

This FAQ was started back in the days of Windows 3.1 and Winsock 1.1. It thus used to have a lot of legacy baggage that was just noise to most programmers today.

In late 2009, I decided it was high time that I refocused the FAQ on modern Windows, which I’ve defined as Windows NT 4.0 SP4 and its direct descendants: all server-class versions of Windows from Windows 2000 forward and all desktop-class versions of Windows from Windows XP forward. I specifically exclude old versions of Windows NT, the 16-bit versions of Windows, and their Frankenstein hybrids, Windows 95/98/ME.

Why target NT 4.0 SP4 specifically? This was the first version of Windows that was both not DOS-based and that included the current version of Winsock, v2.2.2. (Most people just say “Winsock 2.”)

Winsock 2 also came with Windows 98, and was available as an add-on for Windows 95, though both of these do have some differences and limitations compared to NT 4 SP4. Legacy information for these and older systems is now in a separate history article, which also answers the question of why the “current” version of the Winsock spec is over a decade old. It includes much of historical interest.

Most of the FAQ still applies to Winsock 1.1 and BSD Sockets, simply because these are largely backwards-compatible APIs. I advise on how to choose among these alternatives in this FAQ item. In addition, the FAQ has one article covering Winsock alternatives for other operating systems.

The FAQ doesn’t cover Windows CE (or Pocket PC, or Windows Mobile, or Windows Phone, or whatever they’re calling the damn thing this year) in any depth. The last time I looked into it, when WinCE 4 was current, its Winsock implementation was rather crippled. The FAQ does therefore include some workarounds for missing features. I don’t know if newer versions of the OS are closer to their desktop cousins in this regard.

This FAQ assumes you are using development tools that are new enough to include Winsock support. It hasn’t been necessary to download a separate Winsock SDK for many years. If you truly are using tools so old they don’t have things like winsock.h, you can try installing the Windows Platform SDK. It includes Microsoft’s Winsock SDK, and thus works best with Visual C++. If possible, you should simply upgrade your development tools. Microsoft has been giving away perfectly usable versions of their Visual Studio components for years now. For Winsock programming, you want Visual C++ Express. Microsoft has said they’re going to keep offering this, so don’t worry that it might go away some day. It might, but I don’t think it will go away any sooner than its direct competition, things like MinGW and Cygwin.

Speaking of, the FAQ’s code is supposed to build with the MinGW and Cygwin versions of GCC. It’s tested primarily with modern versions of Visual C++, but we do try for compatibility. You’ll have to work out the build commands on your own, though.

0.8 - Programming Language Bias

This FAQ is biased towards C, with some C++ as well. There are a number of reasons I don’t use some other language:

  1. C is the lingua franca of Windows programming. Other languages may be more popular for writing Windows programs, but at bottom, Windows is based on C.

  2. The Winsock API derives from the C-centric Unix world’s BSD Sockets API.

  3. Every other language I’m aware of that’s commonly used on Windows already has some language-specific way to do network programming. You no longer have to write to the Winsock API in these languages, as you did in the bad old days.

Problems that only affect, say, Visual Basic, are not covered in the FAQ. The FAQ’s Resources section and the FAQ item Can I use Winsock with { My Favorite Language }? may be of some use.

0.9 - Protocol Bias

This FAQ only covers the TCP/IP transport protocol suite at this time, simply because I’ve never programmed for any other transport. Winsock supports many other transports, but I can’t even help you to find info about them, other than pointing you to places to ask questions.

0.10 - Acknowledgements

A FAQ is never an isolated thing. It takes many people, from patient gurus willing to share their knowledge, down to the masses of ignorant newbies posting the same damn questions yet again. Without gurus, there can be no accuracy. Without newbies, there’s no grist for the mill. And without everyone from newbies on up, there’s no point in having a FAQ.

My first contribution, as mentioned above, is Mark Towfiq’s original FAQ. Although not much remains of the original material, it did provide this FAQ’s initial core. I might not have decided to create a FAQ in the first place — it probably took an existing, langushing FAQ to prod me.

Bob Quinn (of Windows Sockets Network Programming fame) keeps me accurate and has provided inspiration for a number of the FAQ’s current questions.

Philippe Jounin has provided invaluable input by way of a different perspective. That added perspective has corrected several bits of tunnel vision in this FAQ.

Alun Jones has repeatedly pointed out my various failings. (I’m grateful for this, really I am.) In one way or another, those corrections improve the quality of the information in this FAQ.

As of Spring of 2000, the FAQ began including articles, code and FAQ items from various Winsockers around the globe. I thank these people for letting me kipe their good works. (These items are marked with the original author’s name.)

And of course, there are dozens of others who have sent me email with snippets, corrections, suggestions, pointers and atta-boys. Thanks to you all.

<< Winsock Programmer's FAQ
General Winsock Information >>
Updated Sun Jan 18 2015 04:24 MST   Go to my home page