How the Winsock works in Windows 9X

The mysteries of routing revealed

In the late 80’s and early 90’s our redirector/ gateways were built on a Microsoft ® DOS platform, but with the advent of Windows they were converted and tested using Winsocks. They are usually set up as a redirector gateway software package on the network server and a special Winsock 1.1+ compliant (WINSOCK.DLL) on the client workstations.

When you examine the architecture of Windows Sockets under Windows 9X. As you will discover the WINSOCK.DLL and WSOCK32.DLL files are interfaced with the WSOCK.VXD driver. The job of the WSOCK.VXD is to read the registry to get the list of Winsock providers to load. When you load the WSOCK.VXD, it provides registers for the protocol it handles. When a socket is opened by an application WSOCK.VXD, it determines which Winsock provider it will pass the call to by looking at the socket parameters.

Windows Sockets Supporting Files are described as:

WINSOCK.DLL .. a 16 bit Windows Socket that provides the backward compatibility with existing TCP/IP Windows Sockets.

WSOCK.VXD .. a virtual socket that supports 16 bit Windows Sockets and 32 bit TCP/IP and IPX/SPX Windows Sockets.

WSHTCP.VXD .. the Windows Sockets over TCP/IP which supports 16 bit Windows Sockets and 32 bit TCP/IP Windows Sockets.

WSOCK32.DLL .. the 32 bit Windows Sockets, which support 32 bit TCP/IP Windows Socket Applications.

WSIPX.VXD .. the Windows Sockets over IPX/SPX, which support 32 bit IPX/SPX Windows Sockets.

Additionally, in Windows 95 there are other Winsock providers shipped like AFVXD.VXD. The WSIPX.VXD Winsock provider is part of the NWLink IPX/SPX driver. The AFVXD.VXD driver is generic that is, it is not tied to any specific protocol.

The AFVXD.VXD driver is part of the code installed when TCP/IP is installed on a Windows machine. It does not know about any specific protocol and relies on its own set of assistance drivers to receive information concerning available protocols. In the case of TCP/IP, this driver assistant is WSHTCP.VXD. When you load AFVXD.VXD it reads the registry to get a list of the assistance drivers it needs to load. As each assistance driver is loaded, AFVXD asks it what protocols it implements. AFVXD then tells WSOCK.VXD about these protocols.

The illustration below gives you an idea of how these files  interlink.

Illustration of Standard Winsock 32 API Setup

When a socket is opened, WSOCK.VXD determines if the call should be passed to AFVXD. If it is, then AFVXD sees which assistance matches the socket parameters. The assistance is called to get a driver name to open, and then calls the VTDI.386 driver.

VTDI.386 is an implementation of the TDI (Transport Driver Interface) from Windows NT. So when a protocol wants to provide a TDI interface to be loaded, it registers with VTDI.386 with a VTDI_Register Call. Thereafter, VTDI stores the protocol name and call table into its own internal tables. When the AFVXD has the driver name from the assistance driver, it calls VTDI_Get_Info to get the call table for the driver it wants. Once it has obtained the drivers, it makes TDI calls to the driver as necessary to process the protocol requests.