Share via


Shared Sockets in the SPI

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

Socket sharing between processes in Windows Sockets is implemented as follows. A source process calls WSPDuplicateSocket to obtain a special WSAPROTOCOL_INFOW structure. It uses some interprocess communications (IPC) mechanism to pass the contents of this structure to a target process. The target process then uses the WSAPROTOCOL_INFOW structure in a call to WSPSocket. The socket descriptor returned by this function will be an additional socket descriptor to an underlying socket, which thus becomes shared.

It is the service provider's responsibility to perform whatever operations are needed in the source process context and to create a WSAPROTOCOL_INFOW structure that will be recognized when it subsequently appears as a parameter to WSPSocket in the target process. The dwProviderReserved parameter of the WSAPROTOCOL_INFOW structure is available for the service provider's use, and may be used to store any useful context information, including a duplicated handle.

This mechanism is designed to be appropriate for both single-threaded Windows versions, such as Windows 3.1, and pre-emptive multithreaded Windows versions, such as Windows 95, Windows NT, and Windows 2000. Note that sockets may be shared amongst threads in a given process without using the WSPDuplicateSocket function, because a socket descriptor is valid in all of a process threads.

Note

The Windows Sockets service provider included in Windows Embedded CE does not support socket sharing. You can, however, create a customized service provider that supports shared sockets.

See Also

Concepts

Winsock Service Provider Interface (SPI)