1# net_websocket.h
2
3
4## Overview
5
6Defines C APIs for the WebSocket client module.
7
8**Library**: libnet_websocket.so
9
10**System capability**: SystemCapability.Communication.NetStack
11
12**Since**: 11
13
14**Related module**: [Netstack](netstack.md)
15
16
17## Summary
18
19
20### Functions
21
22| Name| Description|
23| -------- | -------- |
24| [OH_WebSocketClient_Constructor](netstack.md#oh_websocketclient_constructor) ([WebSocket_OnOpenCallback](netstack.md#websocket_onopencallback) onOpen, [WebSocket_OnMessageCallback](netstack.md#websocket_onmessagecallback) onMessage, [WebSocket_OnErrorCallback](netstack.md#websocket_onerrorcallback) onError, [WebSocket_OnCloseCallback](netstack.md#websocket_onclosecallback) onclose) | Constructor used to create a **WebSocketClient** instance. |
25| [OH_WebSocketClient_AddHeader](netstack.md#oh_websocketclient_addheader) (struct [WebSocket](_web_socket.md) \*client, struct [WebSocket_Header](_web_socket___header.md) header) | Adds the header information to the client request. |
26| [OH_WebSocketClient_Connect](netstack.md#oh_websocketclient_connect) (struct [WebSocket](_web_socket.md) \*client, const char \*url, struct [WebSocket_RequestOptions](_web_socket___request_options.md) options) | Connects the WebSocket client to the server. |
27| [OH_WebSocketClient_Send](netstack.md#oh_websocketclient_send) (struct [WebSocket](_web_socket.md) \*client, char \*data, size_t length) | Sends data from the WebSocket client to the server. |
28| [OH_WebSocketClient_Close](netstack.md#oh_websocketclient_close) (struct [WebSocket](_web_socket.md) \*client, struct [WebSocket_CloseOption](_web_socket___close_option.md) options) | Lets the WebSocket client proactively close the connection. |
29| [OH_WebSocketClient_Destroy](netstack.md#oh_websocketclient_destroy) (struct [WebSocket](_web_socket.md) \*client) | Releases the context and resources of the WebSocket connection. |
30