The Winsock Service Provider Interface

Chapter 12

The Winsock Service Provider Interface

The Winsock 2 Service Provider Interface (SPI) is the complement to the Winsock API we have been discussing. As the name implies, the SPI is a service to applications and is not an application. It is written and exposes itself to applications that can load the service either knowingly or unknowingly. The SPI is a part of the Winsock 2 specification and therefore requires the Winsock 2 update if running in Windows 95. Figure 12-1 illustrates the relationship between Winsock applications and the SPI.

There are two parts to the SPI: transport service providers and name space providers. Each part provides distinctly different functionalities. There are two types of transport service providers: layered and base. A layered service provider installs itself into the Winsock catalog above base providers and possibly between other layered providers and intercepts Winsock API calls from applications. A base provider exposes a Winsock interface that directly implements a protocol such as the Microsoft TCP/IP provider. This chapter discusses only layered service providers. When an application creates a socket that matches the characteristics of the layered provider, that layered service provider is called and can intercept Winsock calls.

A name space provider is similar to a transport service provider except that it intercepts the name resolution Winsock API calls, such as gethostbyname and WSALookupServiceBegin. A name space provider installs itself within the name space catalog and is invoked when applications perform name resolution searches that match that name space provider.

Figure 12-1 SPI architecture

Before getting into the specifics, we'll cover some of the basics that pertain to both layered and name space providers. The Winsock Service Provider APIs are contained in the header file WS2SPI.H and SPI applications link with WS2_32.LIB. In addition, there are four types of APIs defined in the SPI. Table 12-1 lists the prefixes for each type as well as whether they belong to service providers or name space providers.

Table 12-1 SPI Function Prefixes

API Prefix

Description

WSC

Installing, removing, or modifying layered and name space providers

WSP

Layered service provider APIs

WPU

Support functions that layered providers use

NSP

Name space providers APIs

In this chapter we'll examine the layered provider interface followed by the name space provider interface.



Network Programming for Microsoft Windows
Network Programming for Microsoft Windows (Microsoft Professional Series)
ISBN: 0735605602
EAN: 2147483647
Year: 2001
Pages: 172
Authors: Anthony Jones

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net