WinHttpWebSocketReceive function

The WinHttpWebSocketReceive function receives data from a WebSocket connection.

Syntax

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

Parameters

hWebSocket

Type: HINTERNET

Handle to a WebSocket.

pvBuffer

Type: PVOID

Pointer to a buffer to receive the data.

dwBufferLength

Type: DWORD

Length of pvBuffer, in bytes.

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.

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 send is pending, or the receive channel has already been closed.
ERROR_INVALID_PARAMETER
A parameter is invalid.
ERROR_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

   
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