subject: Winsock - How Does Winsock Work?
[print this page] The Windows Socket API (simply shortened to Winsock later on) is a technical specification that tells Windows how its networking software should interact with various network services, like TCP/IP, the protocols behind the Internet. The specifications describe two separate interfaces, the Application Programming Interface (API) and the Service Provider Interface (SPI). The API is used by developers that create applications, and the SPI is used by developers that create network software to put new protocols into the system. Each interface, the API and the SPI, signifies a contract. The API says that an application will work correctly with any software that implements the protocol. The SPI says that a protocol added to Windows will work with an application that implements the protocol.
When Winsock first came out, the contracts served an important purpose, but they have since been made obsolete, and now only serve academic purposes. When the second version of Windows Sockets was released, there was no known commercial application that exists which uses the IPX/SPX protocols. Microsoft included a high quality version of the TCP/IP stack in all recent editions of their Windows operating system and there are not any independent alternatives, at least none of any significance, and there is no interest in using protocols other than TCP/IP.
Winsock is based upon an Application Programming Interface called Berkeley sockets, BSD sockets for short, but it also features additional functions that allow it to conform to the standard programming model utilized in the Windows environment. Due to the differences between the Windows platform and UNIX, which is what BSD sockets originated with, there were some problems that were unable to be avoided, even though Windows Sockets contained nearly all the features found in BSD sockets. Windows Sockets increased the amount of functions found in BSD sockets by presenting asynchronous sockets that were non-blocking.
The design purpose of Winsock was to keep it moderately easy for developers to create ports of their socket-based apps from the UNIX platform to the Windows platform. They did not want to make an API that would only allow for newly written programs to work with the Windows operating system. So Windows Sockets included a number of features that were created to make it easy for developers to port already coded programs over to the Windows environment. A lot of traditional TCP/IP programs utilized features that were specific to a UNIX system, and recreating these on the Windows platform causes problems. Within a short time span, developers gave up on porting already created programs and just decided to develop Windows specific applications from scratch.