6.5 Supporting Connect and Disconnect Data with a WSH DLL

Some transports, such as DECNet and OSI TP4, support connect and disconnect data: additional data, not in the normal network data stream, that is sent on the wire along with connect or disconnect requests. Typically, connect and disconnect data is used for operations like application-level version negotiation.

TDI supports the transmission of connect and disconnect data in the TDI_CONNECTION_INFORMATION structure, which has members specifying the UserDataLength, UserData, OptionsLength, and Options. This structure is passed in TDI connect, accept, and disconnect requests by kernel-mode TDI clients.

However, Windows Sockets does not provide input parameters for connect data to the connect function or for disconnect data to the shutdown and closesocket functions. WSH DLLS can add support for connect and disconnect data for applications that call the Windows Sockets setsockopt and getsockopt functions.

The setsockopt function can be called to specify connect and disconnect data to be sent to a remote node, and getsockopt can be called to retrieve connect and disconnect data sent from the remote node. To support this, the following socket options are defined in the Windows NT header file winsock.h:

/*
 * Options for connect and disconnect data and options. Used only by
 * non-TCP/IP transports such as DECNet, OSI TP4, etc.
 */
#define SO_CONNDATA    // connect data
#define SO_CONNOPT     // connect options
#define SO_DISCDATA    // disconnect data
#define SO_DISCOPT     // disconnect options
#define SO_CONNDATALEN // connect data length, in bytes
#define SO_CONNOPTLEN  // connect options length
#define SO_DISCDATALEN // disconnect data length
#define SO_DISCOPTLEN  // disconnect options length
 

How an application uses these options in conjunction with getsockopt and setsockopt depends on whether the application is a server or client (see Section 6.4.1 or 6.4.2, respectively), and on how the application uses the transmitted connect data. For transports, such as DECNet, that have a preexisting definition of connect data different from what is described here, a WSH DLL translates between the transport's semantics and the semantics expected by Windows Sockets, making calls to getsockopt and setsockopt.

Connect and disconnect options are effectively the same as connect and disconnect data from the standpoint of Windows Sockets. These are actually a buffer of data passed to the transport prior to the connect or disconnect, and a buffer containing data that is retrieved following a connect or disconnect. Consequently, an application uses connect or disconnect options in much the same manner as connect or disconnect data. The only difference is the option names used for the parameter passed to getsockopt and setsockopt; for example, SO_CONNOPT in place of SO_CONNDATA.