WebSocketBeginServerHandshake function (websocket.h)

The WebSocketBeginServerHandshake function begins the server-side handshake.

Syntax

HRESULT WebSocketBeginServerHandshake(
  [in]           WEB_SOCKET_HANDLE             hWebSocket,
  [in, optional] PCSTR                         pszSubprotocolSelected,
  [in, optional] PCSTR                         *pszExtensionSelected,
  [in]           ULONG                         ulExtensionSelectedCount,
  [in]           const PWEB_SOCKET_HTTP_HEADER pRequestHeaders,
  [in]           ULONG                         ulRequestHeaderCount,
  [out]          PWEB_SOCKET_HTTP_HEADER       *pResponseHeaders,
  [out]          ULONG                         *pulResponseHeaderCount
);

Parameters

[in] hWebSocket

Type: WEB_SOCKET_HANDLE

WebSocket session handle returned by a previous call to WebSocketCreateServerHandle.

[in, optional] pszSubprotocolSelected

Type: PCSTR

A pointer to a sub-protocol value chosen by the application. Must contain one subprotocol.

[in, optional] pszExtensionSelected

Type: PCSTR*

A pointer to a list of extensions chosen by the application. Must contain one extension per entry.

[in] ulExtensionSelectedCount

Type: ULONG

Number of extensions in pszExtensionSelected.

[in] pRequestHeaders

Type: const PWEB_SOCKET_HTTP_HEADER

Pointer to an array of WEB_SOCKET_HTTP_HEADER structures that contain the request headers received by the application.

[in] ulRequestHeaderCount

Type: ULONG

Number of request headers in pRequestHeaders.

[out] pResponseHeaders

Type: PWEB_SOCKET_HTTP_HEADER*

On successful output, a pointer to an array or WEB_SOCKET_HTTP_HEADER structures that contain the response headers to be sent by the application.

[out] pulResponseHeaderCount

Type: ULONG*

On successful output, number of response headers in pResponseHeaders.

Return value

Type: HRESULT

If the function succeeds, it returns S_OK.

If the function fails, it returns one of the following or a system error code defined in WinError.h.

Return code Description
E_INVALID_PROTOCOL_FORMAT
Protocol data had an invalid format.

Remarks

To complete the server-side handshake, applications must call WebSocketEndServerHandshake or any of the session functions. Once the client-server handshake is complete, the application may use the session functions.

Requirements

Requirement Value
Minimum supported client Windows 8 [desktop apps only]
Minimum supported server Windows Server 2012 [desktop apps only]
Target Platform Windows
Header websocket.h
Library Websocket.lib
DLL Websocket.dll

See also

WEB_SOCKET_HTTP_HEADER

WebSocketBeginClientHandshake

WebSocketEndClientHandshake

WebSocketEndServerHandshake