WinHttpWebSocketReceive function (winhttp.h)

The WinHttpWebSocketReceive function receives data from a WebSocket connection.

Syntax

WINHTTPAPI DWORD WinHttpWebSocketReceive(
  [in]  HINTERNET                      hWebSocket,
  [out] PVOID                          pvBuffer,
  [in]  DWORD                          dwBufferLength,
  [out] DWORD                          *pdwBytesRead,
  [out] WINHTTP_WEB_SOCKET_BUFFER_TYPE *peBufferType
);

Parameters

[in] hWebSocket

Type: HINTERNET

Handle to a WebSocket.

[out] pvBuffer

Type: PVOID

Pointer to a buffer to receive the data.

[in] dwBufferLength

Type: DWORD

Length of pvBuffer, in bytes.

[out] pdwBytesRead

Type: DWORD*

Pointer to a DWORD that receives the number of bytes read from the connection at the end of the operation. This is set only if WinHttpWebSocketReceive returns NO_ERROR and the handle was opened in synchronous mode.

[out] peBufferType

Type: WINHTTP_WEB_SOCKET_BUFFER_TYPE*

The type of a returned buffer. This is only set if WinHttpWebSocketReceive returns NO_ERROR and the handle was opened in synchronous mode.

Return value

Type: DWORD

NO_ERROR on success. Otherwise an error code.

Description
ERROR_INVALID_OPERATION
A close or receive is pending, or the receive channel has already been closed.
ERROR_INVALID_PARAMETER
A parameter is invalid.
ERROR_WINHTTP_INVALID_SERVER_RESPONSE
Invalid data was received from the server.
ERROR_WINHTTP_OPERATION_CANCELLED
The operation was cancelled because WinHttpWebSocketClose was called to close the connection.

Requirements

Requirement Value
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