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:
- 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.
- 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. Most of the traffic on these groups
has to do with TCP/IP, but questions about other network protocols are
appropriate.
The comp.protocols.tcp-ip newsgroup is much broader in scope:
it is about TCP/IP in general, not Winsock programming in particular.
You'll do best to use this group only for issues involving the TCP/IP
protocol itself. (As opposed to issues involving the programming
interface (Winsock) or the high-level protocol you are building on top
of TCP/IP.)
You may also be interested in joining the Winsock 2 mailing
list. This is a low-volume mailing list with many true Winsock experts
as members.
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 a common application 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 Fall 1996. Usenet also has several archives, the most popular
being Google
Groups.
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 has sufficient features for most applications. (See below for a list of what Winsock 2 adds.)
Windows 95 and Windows NT 3.x shipped with Winsock 1.1. All subsequent
versions of Windows ship with Winsock 2. Other operating systems are
covered in a separate FAQ article.
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.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, which you can find at the Evolt Browser Archive.
If you're using Win32s to write 32-bit programs for Windows 3.1, it
includes 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.
Winsock 2 works with Win32's high-efficiency overlapped I/O mechanism.
Since Windows NT derived systems support overlapped I/O within the kernel,
there are significant speed advantages over the more traditional I/O
styles supported by Winsock 1.1. Windows 95 derived systems do not have
overlapped I/O support in the kernel, so there is no speed advantage on
these systems.
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:
- 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 the 800 pound gorilla of network transports, TCP/IP.
- 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.) Recent versions of Windows added new features to
Winsock, implemented some optional features 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.
1.8 - Can Winsock speak { DECNet, IPX/SPX, etc. }?
Winsock 1.1 only had support for TCP/IP in the spec. Several vendors'
Winsock 1.1 stacks did have support for other transports, but the point
is that this was never standardized in the Winsock 1.1 specification.
Winsock 2 standardized support for DECNet, IPX/SPX and OSI transports,
and the spec defines a standardized way for adding support for additional
transports.