![]() |
libwebsockets
Lightweight C library for HTML5 websockets
|
Data Structures | |
| struct | lws_client_connect_info |
Enumerations | |
| enum | lws_client_connect_ssl_connection_flags { LCCSCF_USE_SSL = (1 << 0), LCCSCF_ALLOW_SELFSIGNED = (1 << 1), LCCSCF_SKIP_SERVER_CERT_HOSTNAME_CHECK = (1 << 2) } |
Functions | |
| LWS_VISIBLE LWS_EXTERN struct lws * | lws_client_connect_via_info (struct lws_client_connect_info *ccinfo) |
| LWS_VISIBLE LWS_EXTERN struct lws *LWS_WARN_UNUSED_RESULT | lws_client_connect (struct lws_context *clients, const char *address, int port, int ssl_connection, const char *path, const char *host, const char *origin, const char *protocol, int ietf_version_or_minus_one) LWS_WARN_DEPRECATED |
| LWS_VISIBLE LWS_EXTERN struct lws *LWS_WARN_UNUSED_RESULT | lws_client_connect_extended (struct lws_context *clients, const char *address, int port, int ssl_connection, const char *path, const char *host, const char *origin, const char *protocol, int ietf_version_or_minus_one, void *userdata) LWS_WARN_DEPRECATED |
| LWS_VISIBLE LWS_EXTERN int | lws_init_vhost_client_ssl (const struct lws_context_creation_info *info, struct lws_vhost *vhost) |
| LWS_VISIBLE LWS_EXTERN int | lws_http_client_read (struct lws *wsi, char **buf, int *len) |
| LWS_VISIBLE LWS_EXTERN void | lws_client_http_body_pending (struct lws *wsi, int something_left_to_send) |
#include <lib/libwebsockets.h>
enum lws_client_connect_ssl_connection_flags - flags that may be used with struct lws_client_connect_info ssl_connection member to control if and how SSL checks apply to the client connection being created
| LWS_VISIBLE LWS_EXTERN struct lws* LWS_WARN_UNUSED_RESULT lws_client_connect | ( | struct lws_context * | clients, |
| const char * | address, | ||
| int | port, | ||
| int | ssl_connection, | ||
| const char * | path, | ||
| const char * | host, | ||
| const char * | origin, | ||
| const char * | protocol, | ||
| int | ietf_version_or_minus_one | ||
| ) |
#include <lib/libwebsockets.h>
lws_client_connect() - Connect to another websocket server
| clients | Websocket context |
| address | Remote server address, eg, "myserver.com" |
| port | Port to connect to on the remote server, eg, 80 |
| ssl_connection | 0 = ws://, 1 = wss:// encrypted, 2 = wss:// allow self signed certs |
| path | Websocket path on server |
| host | Hostname on server |
| origin | Socket origin name |
| protocol | Comma-separated list of protocols being asked for from the server, or just one. The server will pick the one it likes best. If you don't want to specify a protocol, which is legal, use NULL here. |
| ietf_version_or_minus_one | -1 to ask to connect using the default, latest protocol supported, or the specific protocol ordinal |
This function creates a connection to a remote server
| LWS_VISIBLE LWS_EXTERN struct lws* LWS_WARN_UNUSED_RESULT lws_client_connect_extended | ( | struct lws_context * | clients, |
| const char * | address, | ||
| int | port, | ||
| int | ssl_connection, | ||
| const char * | path, | ||
| const char * | host, | ||
| const char * | origin, | ||
| const char * | protocol, | ||
| int | ietf_version_or_minus_one, | ||
| void * | userdata | ||
| ) |
#include <lib/libwebsockets.h>
lws_client_connect_extended() - Connect to another websocket server
| clients | Websocket context |
| address | Remote server address, eg, "myserver.com" |
| port | Port to connect to on the remote server, eg, 80 |
| ssl_connection | 0 = ws://, 1 = wss:// encrypted, 2 = wss:// allow self signed certs |
| path | Websocket path on server |
| host | Hostname on server |
| origin | Socket origin name |
| protocol | Comma-separated list of protocols being asked for from the server, or just one. The server will pick the one it likes best. |
| ietf_version_or_minus_one | -1 to ask to connect using the default, latest protocol supported, or the specific protocol ordinal |
| userdata | Pre-allocated user data This function creates a connection to a remote server |
| LWS_VISIBLE LWS_EXTERN struct lws* lws_client_connect_via_info | ( | struct lws_client_connect_info * | ccinfo | ) |
#include <lib/libwebsockets.h>
lws_client_connect_via_info() - Connect to another websocket server
| ccinfo | pointer to lws_client_connect_info struct This function creates a connection to a remote server using the information provided in ccinfo. |
| LWS_VISIBLE LWS_EXTERN int lws_init_vhost_client_ssl | ( | const struct lws_context_creation_info * | info, |
| struct lws_vhost * | vhost | ||
| ) |
#include <lib/libwebsockets.h>
lws_init_vhost_client_ssl() - also enable client SSL on an existing vhost
| info | client ssl related info |
| vhost | which vhost to initialize client ssl operations on |
You only need to call this if you plan on using SSL client connections on the vhost. For non-SSL client connections, it's not necessary to call this.
The following members of info are used during the call
- options must have LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT set,
otherwise the call does nothing
- provided_client_ssl_ctx must be NULL to get a generated client
ssl context, otherwise you can pass a prepared one in by setting it
- ssl_cipher_list may be NULL or set to the client valid cipher list
- ssl_ca_filepath may be NULL or client cert filepath
- ssl_cert_filepath may be NULL or client cert filepath
- ssl_private_key_filepath may be NULL or client cert private key
You must create your vhost explicitly if you want to use this, so you have a pointer to the vhost. Create the context first with the option flag LWS_SERVER_OPTION_EXPLICIT_VHOSTS and then call lws_create_vhost() with the same info struct.