1# Civetweb API Reference 2 3### `mg_connect_websocket_client( host, port, use_ssl, error_buffer, error_buffer_size, path, origin, data_func, close_func, user-data);` 4 5### Parameters 6 7| Parameter | Type | Description | 8| :--- | :--- | :--- | 9|**`host`**|`const char *`|The hostname or IP address of the server| 10|**`port`**|`int`|The port on the server| 11|**`use_ssl`**|`int`|Use SSL if this parameter is not equal to zero| 12|**`error_buffer`**|`char *`|Buffer to store an error message| 13|**`error_buffer_size`**|`size_t`|Size of the error message buffer including the NUL terminator| 14|**`path`**|`const char *`|The server path to connect to, for example `/app` if you want to connect to `localhost/app`| 15|**`origin`**|`const char *`|The value of the `Origin` HTTP header| 16|**`data_func`**|`mg_websocket_data_handler`|Callback which is used to process data coming back from the server| 17|**`close_func`**|`mg_websocket_close_handler`|Callback which is called when the connection is to be closed| 18|**`user_data`**|`void *`|User supplied argument| 19 20### Return Value 21 22| Type | Description | 23| :--- | :--- | 24|`struct mg_connection *`|A pointer to the connection structure, or NULL if connecting failed| 25 26### Description 27 28The function `mg_connect_websocket_client()` connects to a websocket on a server as a client. Data and close events are processed with callback functions which must be provided in the call. 29 30Civetweb supports both IPv4 and IPv6 communication, but only if the use if IPv6 has been enabled at compile time. When running an application it is possible to check if IPv6 addressing is available by calling the [`mg_check_feature()`](mg_check_feature.md) function with the `USE_IPV6` parameter. 31 32### See Also 33 34* [`mg_check_feature();`](mg_check_feature.md) 35* [`mg_connect_client();`](mg_connect_client.md) 36* [`mg_connect_client_secure();`](mg_connect_client_secure.md) 37