WinHttpWebSocketShutdown function

The WinHttpWebSocketShutdown function sends a close frame to a WebSocket server to close the send channel, but leaves the receive channel open.

Syntax

WINHTTPAPI DWORD WinHttpWebSocketShutdown(
  HINTERNET hWebSocket,
  USHORT    usStatus,
  PVOID     pvReason,
  DWORD     dwReasonLength
);

Parameters

hWebSocket

Type: HINTERNET

Handle to a WebSocket.

Note  WinHttpWebSocketShutdown does not close this handle. To close the handle, call WinHttpCloseHandle on hWebSocket once it is no longer needed.

 

usStatus

Type: USHORT

A close status code. See WINHTTP_WEB_SOCKET_CLOSE_STATUS for possible values.

pvReason

Type: PVOID

A detailed reason for the close.

dwReasonLength

Type: DWORD

The length of pvReason, in bytes.

If pvReason is NULL, this must be 0. This value must be within the range of 0 to 123.

Return Value

Type: DWORD

With the following exception, all error codes indicate that the underlying TCP connection has been aborted.

Description
ERROR_IO_PENDING
The operation will complete asynchronously.

Remarks

WinHttpWebSocketShutdown sends a close frame and prevents additional data from being sent over the WebSocket connection. It does not close the receive channel. Use WinHttpWebSocketClose when you want to completely close the connection and prevent any subsequent receive operations.

The application is responsible for receiving the close frame from the server (through regular receive operations).

After WinHttpWebSocketShutdown is called, the application can call WinHttpWebSocketClose if it does not want to receive a close frame on its own and delegate it to the stack.

Requirements

   
Minimum supported client Windows 8 [desktop apps only]
Minimum supported server Windows Server 2012 [desktop apps only]
Target Platform Windows
Header winhttp.h
Library Winhttp.lib
DLL Winhttp.dll

See Also

WINHTTP_WEB_SOCKET_CLOSE_STATUS

WinHttpCloseHandle

WinHttpWebSocketClose