WinHttpWebSocketClose function

The WinHttpWebSocketClose function closes a WebSocket connection.

Syntax


DWORD WINAPI WinHttpWebSocketClose(
  _In_      HINTERNET hWebSocket,
  _In_      USHORT usStatus,
  _In_opt_  PVOID pvReason,
  _In_      DWORD dwReasonLength
);

Parameters

hWebSocket [in]

Type: HINTERNET

Handle to a WebSocket.

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

usStatus [in]

Type: USHORT

A close status code. See WINHTTP_WEB_SOCKET_CLOSE_STATUS for possible values.

pvReason [in, optional]

Type: PVOID

A detailed reason for the close.

dwReasonLength [in]

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_INVALID_OPERATION

A close or send is pending.

ERROR_INVALID_PARAMETER

A parameter is invalid.

ERROR_INVALID_SERVER_RESPONSE

Invalid data was received from the server.

 

Remarks

WinHttpWebSocketClose completely closes a WebSocket connection. To close the send channel while still leaving the receive channel open, use WinHttpWebSocketShutdown.

It is possible to receive a close frame during regular receive operations. In this case, WinHttpWebSocketClose will also send a close frame.

The close timer can be set by the property WINHTTP_OPTION_WEB_SOCKET_CLOSE_TIMEOUT. The default is 10 seconds.

Requirements

Minimum supported client

Windows 8 [desktop apps only]

Minimum supported server

Windows Server 2012 [desktop apps only]

Header

Winhttp.h

Library

Winhttp.lib

DLL

Winhttp.dll

See also

WinHttpWebSocketShutdown
WinHttpCloseHandle
WINHTTP_WEB_SOCKET_CLOSE_STATUS

 

 

Community Additions

ADD
Show:
© 2014 Microsoft