Modernized the “Winsock for Non-Windows Systems” article.


New navbar icons.


Finished modernizing the Winsock Resources section. Lots of stuff there got moved into the history of Winsock article, and a fair bit was just removed as irrelevant these days. Merged several of the pages together, as several of them got pared down to just a few links each. The new Other Web Pages page holds most of what was left from this process.


Moved discussion about what packet sniffers are out of the FAQ item on debugging tools into a new article and greatly expanded the discussion. Added history and a lot more detail about the limitations of sniffers and workarounds for those limitations.

Moved discussion of available debugging tools into the debugging tools FAQ item, and removed the Resources section that listed them. The main value of that section was the reviews, most of which hadn’t been updated in a decade, with no prospect for that changing. Better to just list them and let the reader make their own decision.

Still more URL fixes, stale product removals, etc. in Resources section.


Finished modernizing the advanced section of the FAQ.


Expanded the history of Winsock article quite a bit. Divided it up into pure history and Winsock technical detail sections better, and overall made it clearer and more enlightening.

Lots of minor tweaks and cleanups.


Major update to Intro through Intermediate sections of the FAQ, and half the Advanced section. (More coming, just published what I have so far.) A few other bits touched in passing, too. Details:

I finally made the decision to drop Win16, Win9x, Windows NT 3.x, and Winsock 1.1 specific material from the main body of the FAQ. This leaves material that does cover these things generically, but which only covers “modern” versions of Windows specifically. Rather than drop the old material entirely, I created a new history of Winsock article from it.

Major updates to the text, both to fix up problems and to fill in what I’ve learned since I last touched each item. Some FAQ items have been all but rewritten!

Some hopelessly outdated questions removed, a few added, and a few others re-asked to broaden their scope a bit.

Some URL fixes, though the majority of that work is still ahead, since I haven’t gotten to the Resources section yet.

Replaced FreeFind search with Google custom search.

Major CSS and HTML style fixes, plus a little style improvement. The parts of the FAQ that I’ve touched validate now, something they never have.


Weeded the debugging tools page: removed dead products, updated prices, updated reviews of products I still use, cleaned up presentation, etc.

Extracted glossary item about TCP into its own FAQ item.

Renamed FAQ item about UDP to match better with new TCP item.

Several small clarifications and fixes to UDP FAQ items.


Added a link to a poll() wrapper for select() to the BSD sockets compatibility article.


Major refresh. Fixed broken links, primarily.


Rewrote the "maximum number of simultaneous sockets" FAQ item for clarity and to keep up with recent findings.


Fixed a few problems in the packetizing example pointed out by Craig Schmackpfeffer, and added some info explaining the limitations of the code.


Added the How to Packetize a TCP Stream article. This is based on code that was in the How to Use TCP Effectively article, but this new version is standalone, compilable code instead of pseudocode, and it has only one recv() call, instead of two. A double recv() is bad Winsock programming style.

Expanded the old item on detecting a modem connection to deal with the broader issue of detecting any Internet connection. Also, added Elmue’s RAS checking example, which supports this FAQ item. Thanks for the code, Elmue!


Added several libraries and web page links, plus fixed a few FAQ items.


Made links to each of the basic examples in the table of contents, below. Before, there was just the overarching section header (6.1), which didn’t tell you that there were several major items underneath it.


Several minor updates, mainly in the Resources section.


Did another update to the I/O strategies article: I added one new heuristic, and made several improvements to the existing material.


Did a minor re-write on the I/O strategies article. I clarified some my advice on non-blocking sockets (Heuristic 2), split some information out of the old Heuristic 2 into its own item (Heuristic 3, now), and removed some redundant and misleading advice about asynchronous sockets from Heuristic 4. I also added Heuristic 12, on designing your program around the protocol.


Made several clarifications to the BSD sockets compatibility article.


Added an item that has a link that will get you off the Winsock 2 Mailing List.


Split the sample code resources section into two parts: tutorial code and useful code. Also checked and updated all the links, and added links to a few new bits of sample code.


Added info to the question on getting the local IP address and to the page of one of the associated examples noting that essentially all TCP/IP machines have more than one network interface. The new info explains why this is so and how your program can deal with this fact. This also covers issues surrounding multihomed systems.


Added info to the "using sockets on other systems" article about the PalmOS.


Fixed a few problems in the select()-based server example pointed out by Wojtek Pilorz, and added some clarifiying commentary.


Moved the "Is there Winsock for ..." question into its own article, as it was very large. (This has to do with using Winsock and similar mechanisms on non-Windows systems.) Then I enhanced the coverage, particularly in the "Winsock for DOS" area.

Ditto for the new passing a socket to another process article.


As I frequently do, I went back and re-read the firewalls article, and made several minor improvements.


Fixed a typo in the Which I/O Strategy Should I Use? article: to support 1024 sockets with event objects, you need 16 threads, not 64 threads. Kudos for this catch go to John F. Keaveney.

Noted one other method for discovering MAC addresses: the IP Helper API has a function that will return this info. Thanks to Tim Eyre for pointing this out.

Craig Morrison has started several mailing lists for implementors of email, FTP and web (HTTP) programs.

Added a new article on how to pass a socket from one process to another. This is an expansion of information that was already in the FAQ. The original FAQ item discussed how to do it under Winsock 2, but Frank Schmied showed how you can do it under Winsock 1.1 on Win32 as well.

Collected the two existing firewall FAQ items and turned them into a new article, "Dealing with Firewalls". The original FAQ items were article-length already, and I wanted to add info on accessing a server behind a firewall, so it was time to take them out of the main FAQ.


Added an item on the various _WAIT states shown by the netstat tool. It just points readers to the "Debugging TCP" article which has been around for a long time, but I realized that it wasn’t clear that the FAQ covered such issues.


Added info about WinPCap to the packet capturing FAQ item. (WinPCap is a free library used for writing packet sniffers.)


Merged three items in the General section that talked about Winsock versions and where to get Winsock. They really were just several parts of the same question.

Updated the "When is the next revision of the Winsock spec due out?" item to note that Winsock is slowly evolving, though no new specs are coming out.


Fixed a potential bug in the error message lookup function in the basic example programs’ common ws_util.cpp module. (STL’s lower_bound() doesn’t always return “one past the end” when it fails to find what you asked for.)

Added a pair of items on peeking and out-of-band (OOB) data. These are related because they’re both enabled by optional flags to recv() and send().

Alun Jones sent me a whole spate of small additions, and clarifications pointing out the places where what I meant to say and what the FAQ actually says were at odds. Several real technical problems were corrected, too.


There is an implementation of the Unix poll() function for Winsock. Added info about it to the BSD compatibility article.

There were two places mentioning the RPC method of getting the machine’s MAC address. Microsoft has broken this feature in at least one patch for Windows 95 and in Windows "2000". Since the feature wasn’t all that reliable anyway, these references have been replaced with warnings not to use the feature. I could have just removed the references, but the feature is well-known and often recommended because it’s so simple. It’s the FAQ’s place to stand up and say, "This is the wrong answer for this question."


Added an asynchronous I/O client program to the Basic Winsock Examples section.

Added an asynchronous I/O client based on CAsyncSocket instead of calling the Winsock async API directly. These two examples are useful in and of themselves, but they’re also interesting to compare to each other to see how the MFC wrapper helps (and hinders!) over the plain API.

As a result of writing those two programs, I updated the CSocket Considered Harmful article.

Some kind readers pointed out that there is in fact an SSL mechanism built into Windows NT 4.0 SP4+ and Windows "2000". The SSL FAQ item has been updated to reflect this.


Updated the item on getting the machine’s MAC address. It was becoming quite inaccurate.

Added an item discussing how to get SSL encryption for your programs.


Added an item discussing the various reasons why NT Server is the only legitimate server platform for high loads.

Updated the connection backlog item a bit: added info on the backlog limitations in various MS OSes, and discussed why and when this matters.

Added two new items on UDP: "What is UDP?", and "What is UDP good for?".

Split the links to related FAQs out of the Web Pages resource section into their own section.


Added an item regarding the proper value for a server’s connection backlog.


Fixed the description of the Nagle algorithm. I blame the store that sold me all that Jolt. They should never let me buy such things. :)


Added definitions of TCP and UDP to the glossary.


Added a new item, "What if the firewall does not support SOCKS?" This deals with the politics of getting through a firewall where the admins have blocked all but a few ports, and your app is written to use one of the blocked ports.


Updated the glossary with several new items, and improved many others.

Moved the main text of some of the longer glossary items into the main FAQ. The new items are What is the Nagle algorithm?, What is TCP’s sliding window?, What is the silly window syndrome?, and What is the delayed ACK algorithm?.

Added an item for the true newbies, What’s the difference between Winsock and TCP/IP?. I wouldn’t have believed the need for the item if I hadn’t seen the question on a newsgroup....

Added an item covering the newsgroups and mailing lists that cover Winsock and TCP/IP.

Added info on Winsock for the Macintosh (Yes, there is such a beast!)


Today I did a major update to the BSD sockets compatibility article. This includes new info on #include file differences, discussion of BSD’s fcntl() system call, and greatly expanded info on file/socket handle compatiblity under Windows. Also corrected and expanded the “errno vs. WSAGetLastError()” item. There are a few other minor improvements to the article.

Expanded the FAQ item that talked about the FD_SETSIZE limitation of 64 sockets. (This causes select() to not be usable in some situations with more than 64 sockets.) The FAQ item now talks about a related limitation, having to do with Winsock event objects.


Doug Martin rightly pointed out that RAS isn’t available on all systems, so simply using the RasEnumConnections() API to check for an Internet connection through a modem will make the application not run at all on those systems. I have updated the relevant FAQ item to show how to handle this case.


The numbers were literally off by an order of magnitude in my TCP window size item. So, I changed the example from 10BaseT to 100BaseT and recomputed. Now the question matches my predetermined answers. :)


Rewrote the item about TCP window sizes. The new version is clearer and provides more information.

I just found out that the MFC tradition of bad network class design continues in their new CCESocket class. I almost added an item to the main FAQ to discuss it, but then I realized I was starting to get very...shall we say...editorial. So, I converted the existing CSocket item to an article and added the CCESocket material to that.

Reorganized several FAQ answers to be more positive: caveats or warnings are now at the end of items rather than up front. Before, some items sounded naggy, especially to those who already knew the caveats.

Added an item that covers the "are asynch sockets reliable?" issue.


Added an item discussing the TCP window size.

Added a Resources section covering interesting MS Knowledge Base articles.


Added multithreaded server and select()-based server example programs.

Updated basic examples’ Makefile so that it works with several command line compilers: Visual C++ 5.0 (and hopefully 6.0), the free version of Borland C++ 5.5, and Cygnus’ port of GNU C++ 2.91 (Cygwin 1.0).


Added info to the item about detecting abnormal disconnects warning against using keepalives to detect these sorts of problems.


Fixed several “point-0” problems. (Yes, FAQs have them, too!)


Finished the redesign. This also marks the first FAQ announcement in several months.

Added the review of Jones and Ohlund’s Network Programming for Microsoft Windows.

Added an article by Tom Sanfilippo that shows how to use the undocumented WsControl() function. This function is used by Windows 95’s winipcfg program to view and change various IP parameters. There is no documented way to get at a lot of this info, so this article is very welcome! Thanks, Tom!

(I didn’t plan it, but this "FAQ rebirth" occurred on Easter Sunday. Apropriate, no?)


Today I began a total revamp of the FAQ’s look, content and organization. Virtually every FAQ item got minor changes, and several have been completely rewritten.

The FAQ’s organization is rather different now, too. Many of the items from the previous “newbie” and “advanced” sections have been culled to make a new "intermediate" section. Another problem I fixed is that the old FAQ organization required that I always add new items at the end of a section instead of near related items. For the same reason, the previous FAQ organization didn’t allow me to delete or move items. For these reasons and others, if you had hyperlinks to particular items on these pages, they are definitely now broken!

Most importantly for you, the reader, is that I’ve made quite an effort to make this FAQ more maintainable. Hopefully this will decrease the amount of procrastinating I do, so changes and additions will get done on a more timely schedule.

NOTE: I removed all hyperlinks from this point forward since the redesign pretty much made them all bogus.


Added some more info to the BSD Sockets Compatibility tutorial.


Updated the ICMP Ping Example so that it compiles cleaner, and updated the commentary to note that the program still works on Microsoft’s newest platforms (Win98 and Win2K) despite their past threats to remove the API.

Added some new info on the “how many sockets can you have open” problem discussed in Question 3.16. The new info discloses kernel internals that limit the number of sockets you can create on Windows NT 4.0 and Windows "2000". The item also includes some empirical data I’ve collected from Internet postings; some conclusions are drawn based on this data and the known kernel algorithms. I also added some info on increasing the low hard limit imposed under Win9x.

Improved the accuracy of the info on waitable timers in Question 2.14.

Added the Search function, courtesy of FreeFind.

Added Question 2.18, regarding the Winsock link library. (This question comes up with distressing frequency, so I broke down and added it to the FAQ. What is the world coming to? :-/)


Updated the new “raw socket capabilities” table in item 3.1 with new information on what Windows 2000 will support.


Fixed several broken links and added a number of new items to the Debugging page of the FAQ’s Resources section.

Improved item 2.15, regarding the best way to send a broadcast packet.

Changed item 3.17. It used to say that only buggy Winsock stacks and LSPs limited the number of sockets per select() to 64, but I’ve been reliably informed that at least one respected Winsock vendor’s stack behaves this way, and they aren’t willing to change it. So, the FAQ item now recommends against trying to force your way past this limitation.

Improved item 3.18, to note that its advice won’t help work around a certain Windows 9x bug, though it seems like it should help.

I just found out a way to get quasi-dup2() functionality under Winsock. Thus, the BSD Compatibility and Question 3.3 items have been updated.

Added item 3.21, to point people wanting to know about the control bits in a TCP packet to the Debugging TCP tutorial which covers this.

Added item 2.17, regarding advice for choosing server ports.


Revamped Tutorial 4. I reworked the existing text, added some examples and went into more depth on some topics. More importantly, I changed the title from "Why Does Winsock Keep Corrupting My Data?" to "How to Use TCP Effectively". In the eight months that the tutorial has been online, I’ve come to realize that the original title was not quite accurate, so that many who should have read the tutorial were skipping over it because they didn’t realize that it applied to problems they were having.

Updated Question 2.14 with information on aborting a wait on an event object by using a waitable timer.

Added Question 2.15, regarding broadcasting.

Split Question 2.8: the new Q2.8 deals with normal TCP disconnects. The rest of the information from the old Q2.8, having to do with abnormal network disconnects, is now in Question 2.16.

Reports indicate that my getifaces sample fails on Windows 95, so I’ve updated that page to reflect this.


Tweaked some of the answers in Section 3 for accuracy.


Item 3.14 basically said “you can’t do that“ to people wanting to do low-level network I/O. That’s only true if you’re just talking about the Winsock API. The current answer for that question breaks out of that box and provides pointers to other mechanisms for accessing the lower levels of the network stack.

I normally don’t announce updates to the pages in the Resources section, because most often the changes merely reflect a site that has moved or something similarly trivial. This latest change is fairly significant, though: the Web Pages page now has links to a number of related FAQs.


Small changes to this main page and also to the Mirrors section.


Added item 0.6, which explains the FAQ’s programming language bias and the reasons for it. Note that I moved the old item 0.6 (Acknowledgements) to 0.7. I did this because I prefer to keep the Acknowledgements section in its traditional place, at the end of the introductory material.

Simplified the answer to Question 0.5, which discusses the reasons I prefer not to answer Winsock questions by email.

Updated Question 1.6, mainly with more information on alternatives to Winsock for DOS programmers. Also added a paragraph to clear up the confusion between a DOS program and a console mode program which happens to run in a "DOS box" on Win32. (Many people, when they say they want to write a Winsock program that runs under DOS, really just want a console mode program.)


(Saint Patrick’s Day!) Updated Question 2.7 again, this time to clarify the language issues some more.

Revamped the answer to Question 3.9 again. I looked back over the previous update and was still unhappy with the way the item was phrased. So, I started working on it and ended up rewriting the whole item!

As a result of the previous change, I touched up Question 3.10, because it referred to the old Q3.9 language.


Updated Question 2.7 to better cover the issues associated with programming Winsock in languages other than C or C++.

Clarified the answer to Question 3.9, regarding warnings about accessing a single socket from multiple threads.

Added information to Tutorial 4 on sending non-integer data across platforms.


Fixed a bug in basic-client.cpp from Example 10. Thanks for the bug catch go to Jerome Jacobsen.


Made a minor update to Question 2.10.

Added Question 2.14, having to do with timeouts and blocking Winsock functions.


Updated the OS/2 entry in Question 1.6.


Reworked Introduction page to be part of the main FAQ (Section 0).


Added the basic-server example to Example 10.


Added a few items to the BSD sockets compatibility tutorial.


Fixed a problem with Question 2.8, and generally improved the answer to that question and to Question 2.12.


Added the first “basic Winsock client” example program. More clients and also some server programs will follow in the series.


Touched up several FAQ entries that refered to other people’s copy of the Lame List to point to the version I just added.


Added a copy of The Lame List to the Tutorials section. Must reading!

Several minor changes, especially to the newer items added on the sixth of this month.


Added Tutorial 5, which introduces the reader to the black magic of low-level TCP debugging. In particular, it covers the netstat tool and the TCP/IP state/transition diagram — how to read it, what to do when you get into problem states, how to diagnose the current state of the system, etc.

Reworked Question 2.9 a bit as a result of the new Tutorial. (It used to be called "How can I debug my Winsock program?", for example. Clearly inappropriate given the new material, and what the Question actually covered.)

Updated Question 2.8. The new Answer is more cosmopolitan in its advice, and it also addresses abnormal-disconnect issues, whereas the previous Answer only covered normal disconnects.


Added Question 2.12, having to do with the proper way to close a socket.

Added Question 2.13, regarding MFC’s CAsyncSocket and CSocket classes.

Added Question 3.18, regarding a method to bypass the routing layer on a machine with multiple network interfaces.

Added Question 3.19, which is about using SOCKS to drill through a firewall.

Added Question 3.20, regarding whether it is a good plan to call bind() in a client program.

Numerous other minor updates.


Added support for changing the TTL value to the raw sockets ping program.


Updated the much-neglected Section 1.

I just discovered that Question 2.12, which I added almost two months ago, is essentially identical to Question 2.2. You know your FAQ is getting big when.... Anyway, I nixed Question 2.12, and used its text in place of the less-well-written 2.2 text.


Added Reviews section, and wrote the first five book reviews for it.


Added Questions 3.16 and 3.17, regarding issues of “how many sockets can Winsock handle.”


Added Tutorial 3. This material largely supercedes Questions 3.4 and 3.7, so those items have also changed.

Turned Questions 2.12 and 2.13 into Tutorial 4.

Added a new Question 2.12, regarding how to speak various common protocols, like HTTP and FTP.

Added a new Question 3.4, regarding using the SNMP API for accessing the routing table, the ARP table, the interface list, etc. (It replaces the old Question 3.4, which was superceded by Tutorial 3.)

Updated several of the entries regarding Windows 98.


Added two more network monitoring packages to the Debugging portion of the FAQ’s Resources section.

Replaced Tutorial 2 with a new, completely-rewritten version.

1998.05.19 and 1998.05.20

Improved the wording of Question 3.15.


Fixed a broken link.


Updated Question 1.9 and also the Resources section.


Added info on structure-padding issues to Question 2.13.

Updated Question 2.10 by removing the rumor that FormatMessage can return error messages for Winsock error numbers. I have since found out that at best this is undocumented behavior that only works on one or two of Microsoft’s Winsock implementations. It is by no means a universal thing.


Split Resources page up so that each sub-section has its own page.

Put the index pages for all the sections with their own directory in that directory. Now, the HTML file of the same name is just a redirector. For example, the old examples.html file is now at examples/index.html, and examples.html automatically forwards you to the new page.

Added a few new sniffers to the Debugging Resources subsection and updated most of the the existing entries.


Added a bit of info to the Get Interface List example.

Added a bug note to the Get MAC Address (NetBIOS version) example.


Added Questions 3.13 and 3.14, concerning raw sockets and such. Also updated Question 3.1 to reference the new questions for more information.

Added Question 3.15, concerning the time and place for turning off the Nagle algorithm.

Added a number of glossary entries.


Added the “raw ping” example. Also touched up the answers to questions 3.1, 3.2, 3.8 and 1.7.


Added a new tutorial, Winsock for the Impatient.

Updated the Glossary some, mainly the router, gateway and bridge entries and other related things.


Updated Questions 1.3 and 1.8 with better Winsock 2 info.

Expanded Question 3.9 and split it up into Questions 3.9 through 3.11. Because they are all related, I didn’t put the new questions at the end of the list, as I usually do. Instead, the old Question 3.10 is now Question 3.12.

Had one of those periodic whole-FAQ editing fits, and ended up re-working a lot of the text, partly for accuracy, partly to fill in missing detail, and partly just so that it reads better.


Fixed a minor problem in Question 3.8.

Added Question 2.10, which explains how to get a readable error message from a Winsock error number.

Added Question 2.11, which sheds some light on the poorly-understood WSAEWOULDBLOCK error.

Added Question 2.12, which deals with the common misconceptions about how TCP “should” work versus how it actually does work.

Added Question 2.13, which talks about “network order” for integers.

Added Question 3.9, which deals with the behavior of asynchronous sockets in a multithreaded program.

Added Question 3.10, which explains how to tell if the modem is connected on systems with dial-up networking.

Added the “get interfaces” example.


Added the Tutorials section. The first one is the information from the way-too-long answer to Question 2.4, in article format. The new answer to Question 2.4 mainly just summarizes the article and points readers to it for more information.


Added Winsock debugging tools section to Resources page.

Added Question 2.9 to introduce the new debugging tools section.


Updated the Introduction page significantly. If you haven’t read through it recently, you may want to give it a quick skim, especially the “future directions” section and the short-and-unoriginal legal statement.


Updated Question 2.7 to be correct some misconceptions present in earlier versions.

Expanded and reorganized the Resources section significantly.

Clarified and enhanced Question 1.6.


Added the “get MAC address” examples (NetBIOS and RPC methods). Also added Question 3.8 to introduce those examples.

Enhanced Question 3.1, adding more details about the support for raw sockets on Microsoft and other Winsock implementations.

Split Question 2.4 into Questions 2.4a, 2.4b, and 2.4c. Each part is now greatly enhanced, resulting in a much broader and tolerant answer. [Obsolete — see the note for 1998.01.19 for newer info].


Added some info to Question 3.3. Also changed the wording to use Microsoft’s preferred term “process” rather than “task.”


Added the Glossary


Added this list.

Improved answer to Question 2.3, including a second method for getting the local IP address, and adding some caveats to the first method.

Refined answer to Question 2.4, making the distinction between non-blocking and blocking sockets. What was previously called non-blocking is now called “asynchronous.” (This was not incorrect, just imprecise.) Also corrected some misconceptions about the behavior of blocking sockets.


First announcement for the FAQ posted to Usenet.

Go back to Winsock Programmer's FAQ Go to my home page