Winsock Programmer's FAQ
Section 1: General Winsock Information

1.1 - What is Winsock?

The Windows Sockets (abbreviated "Winsock" or "WinSock") specification defines a network programming interface for Microsoft Windows which is based on the "socket" paradigm popularized in BSD Unix. It encompasses both familiar Berkeley socket style routines and a set of Windows-specific extensions:

  1. Winsock 1 apps can ask Winsock to send notifications in window messages. This allows your program to handle both the network, UI issues, and background processing without having to worry about concurrency.
  2. Winsock 2 adds many features. See below for details.

Winsock 2.x defines two interfaces: an application programming interface (API) which shields application developers from underlying layers, and a service provider interface (SPI) which allows transparent extensions to a Winsock stack. Through proper use of the API, a Winsock application can work over various network transport protocols and Winsock implementations.

(By the way, most people just say "Winsock 2" when speaking of the current version of Winsock, because the newer versions just contain edits and clarifications to the original spec.)

You should get a copy of the API specification if you plan on programming for Winsock.

1.2 - What's the difference between Winsock and TCP/IP?

Networks are made of several layers. Network people talk about those layers in terms of the OSI network model.

TCP/IP is a network protocol, meaning that it is at layers 3 through 4 in the OSI model. A network protocol provides services like addressing, data transport, routing, and logical connections across a network. Two computers must use the same network protocol if programs running on those computers are to communicate. Other common network protocols include Novell's IPX, 3Com/IBM/Microsoft's NetBIOS and Apple's AppleTalk. TCP/IP is the most popular network protocol today: virtually all computers support it.

Winsock is an API that lets a Windows program send data over any network transport protocol. There are several functions in Winsock that only work with TCP/IP (e.g. gethostbyaddr()), but there are newer generic versions of all these in Winsock 2 which allow you to use other transports.

1.3 - What newsgroups and mailing lists exist for Winsock and TCP/IP?

The main Winsock newsgroups are comp.os.ms-windows.programmer.tools.winsock and alt.winsock.programming. These only cover Windows network programming issues. Due to TCP/IP's popularity, most of the questions have to do with TCP/IP, but questions about other network protocols are appropriate.

The main TCP/IP newsgroup is comp.protocols.tcp-ip. It is much broader in scope than the Winsock newsgroups: you will find discussions on network management strategies, Unix network programming, the odd interactions between DNS client X and DNS server Y, and other things that have nothing to do with Winsock.

You may also be interested in joining the Winsock 2 mailing list. This is a low-volume mailing list (10 messages a day or so) with many true Winsock experts on it.

If you are implementing an email program (SMTP, POP, IMAP), an FTP program, or a web program (HTTP), Craig Morrison has set up several mailing lists that you may be interested in joining.

If you have questions about common protocol like those above or another common Internet protocol, see this FAQ item for pointers to resources you should find helpful.

Before posting questions to Usenet newsgroups or to mailing lists, search the relevant archives to see if your question has already been asked. Newsgroup and mailing list subscribers tend to be impatient with people who don't do this: it's a waste of their time to point you to places where you could have found the answer on your own. The Winsock 2 mailing list archives go back to the middle of 1996. Usenet also has several archives, the most popular being Google Groups.

1.4 - How do I get off the Winsock 2 Mailing List?

Click the following link and then send the email:

Unsubscribe from Winsock 2 Mailing List.

1.5 - What versions of Winsock are available?

The latest version of Winsock (as of 2000.08.10) is 2.2.2. It is usually just called "Winsock 2" because later revisions just clarify and correct items in the original spec. The other major version out there is 1.1, which is good enough for most applications. (See below for a list of what Winsock 2 adds.)

All versions of Windows since Windows 95 come with Winsock, and there are several versions of Winsock available for Windows 3.1. (Other OSes are covered in a separate FAQ article.) Windows 95 and Windows NT 3.x shipped with Winsock 1.1. Windows 98, Windows ME, Windows NT 4.0 and Windows 2000 ship with Winsock 2.

You can get a Winsock 2 update for Windows 95 from Microsoft's web site. If your development suite is also old, you may also need the Winsock 2 SDK, which you can get as part of the Windows Platform SDK. (Sorry, there's no longer a place where you can get just the Winsock SDK.)

Windows 3.1 and Windows NT 3.x can only support Winsock 1.1, due to kernel limitations.

Windows 3.x does not come with Winsock, but there are many add-ons available. Probably the two most popular options are Microsoft's Wolverine stack and Trumpet Winsock. There are several tradeoffs between these two options. Wolverine is free, works only with Windows for Workgroups 3.1, and only handles LAN connections. Trumpet is inexpensive shareware, works on all Windows 3.1 flavors, and can do LAN, SLIP and PPP connections.

Another option for Windows 3.1 is to install the 16-bit version of Internet Explorer 4.0. You can find this at the Evolt Browser Archive.

If you're using Win32s to write 32-bit programs for Windows 3.1, there is a WSOCK32.DLL that thunks calls down to a 16-bit WINSOCK.DLL, if present. I have successfully used Win32s to run 32-bit Winsock programs over Trumpet Winsock and Microsoft's Wolverine stack.

Keep in mind that you can't copy a Winsock DLL to another machine and expect it to work. You have to get and install a complete network stack, including its associated Winsock layer.

1.6 - What does Winsock 2 have that Winsock 1.1 doesn't?

One of the most important new features is official support for multiple transport protocols. Although Winsock 1.1 was not actually limited to TCP/IP, that was the only protocol that had official support written into the spec. There was no standard way for a vendor to add support for another transport protocol, though a few vendors did do proprietary implementations of other protocols. With Winsock 2, official support for OSI, Novell IPX/SPX and Digital's DECNet exists in the spec, and it's now possible to add support for other protocols in a standard way. More importantly, a program can be written to be transport-independent, so that it works with all of these protocols, without change.

Winsock 2 also adds support for technical initiatives like quality of service (QoS) and multicasting. These technologies will become increasingly important as bandwidth requirements become more regimented and intense. For example, QoS allows a videoconferencing program to reserve a certain amount of bandwidth so that a sudden file transfer, for example, doesn't cause its video to begin breaking up due to a lack of bandwidth. Multicasting allows that videoconferencing application to send audio and video streams to many participants without duplicating data any more than absolutely necessary.

Another important feature of Winsock 2 is complete integration with Win32's unified I/O mechanisms. For example, it is possible to use the Win32 ReadFile() API on a socket instead of recv(). More importantly, Windows NT/2000's overlapped I/O mechanisms can now be used with sockets. Winsock 2 on Windows 9x also implements overlapped I/O with sockets, but because there is no native support in the Windows 9x kernel for overlapped I/O, the mechanism is completely emulated by Winsock.

Winsock 2 also allows for "Layered Service Providers." This enables many neat things, such as security plug-ins: drop in, say, an SSL service provider, and all of a sudden your data is automatically encrypted.

There are a number of other additions to the spec. You can get a complete list of them on sockets.com's Winsock 2 Overview page.

1.7 - When is the next rev of the specification due out?

The current revision (2.2.2) looks pretty durable to me. There are two things that could force Microsoft to create a new version of Winsock:

  1. A new transport protocol comes out that Microsoft wants to support. Currently, Winsock supports all the common transport protocols, and there seems to be no serious competition to replace frontrunners like TCP/IP.
  2. Major changes to an existing network protocol. This is due to happen once IPv6 takes off, because it requires changes to a lot of Winsock-level functionality, especially all the functions that depend on sockaddr_in.

Winsock is in fact evolving slowly, and Microsoft is not documenting these changes with updates to the Winsock spec. (They are documented in MSDN, however.) Windows 98 and Windows 2000 variously added new features to Winsock, implemented some optional ones previously unimplemeted, and created new APIs (e.g. IP Helper) that complement Winsock without directly affecting it. It'd be nice to see these changes collected and standardized in a formal document like the Winsock spec.

The next likely time for major changes to Winsock is when Windows 2000 gets replaced. Your humble author is of the opinion that this will happen sometime in 2003.

1.8 - Can Winsock speak { DECNet, IPX/SPX, etc. }?

Winsock 1.1 only provided real support for TCP/IP. Microsoft, Novell and a few other vendors did provide NetBIOS, IPX/SPX and support for other transport protocols through Winsock, but the point is that this support was never standardized in the Winsock specification.

Winsock 2 changed this by providing standardized support for the DECNet, IPX/SPX and OSI transport protocols. I've heard that ATM's native transport has some semi-official Winsock support as well. (It requires Winsock addons from your ATM card's vendor.) Support for other LAN/WAN transports are likely to follow as demand dictates.


<< Introduction Information for New Winsockers >>
Last modified on 22 September 2001 at 23:48 UTC-7 Please send corrections to tangent@cyberport.com.
< Go to the main FAQ page << Go to the Home Page