lws_client_connect_via_info
https://github.com/warmcat/libwebsockets/issues/396 Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
parent
b6289d1153
commit
5b3736682d
4 changed files with 31 additions and 24 deletions
|
@ -313,29 +313,16 @@ failed:
|
|||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* lws_client_connect() - Connect to another websocket server
|
||||
* @context: 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
|
||||
* lws_client_connect_via_info() - Connect to another websocket server
|
||||
* @i:pointer to lws_client_connect_info struct
|
||||
*
|
||||
* This function creates a connection to a remote server
|
||||
*/
|
||||
|
||||
|
||||
LWS_VISIBLE struct lws *
|
||||
lws_client_connect_info(struct lws_client_connect_info *i)
|
||||
lws_client_connect_via_info(struct lws_client_connect_info *i)
|
||||
{
|
||||
struct lws *wsi;
|
||||
int v = SPEC_LATEST_SUPPORTED;
|
||||
|
@ -438,7 +425,7 @@ bail:
|
|||
|
||||
/**
|
||||
* lws_client_connect_extended() - Connect to another websocket server
|
||||
* DEPRECAATED use lws_client_connect_info
|
||||
* DEPRECATED use lws_client_connect_via_info
|
||||
* @context: Websocket context
|
||||
* @address: Remote server address, eg, "myserver.com"
|
||||
* @port: Port to connect to on the remote server, eg, 80
|
||||
|
@ -479,10 +466,30 @@ lws_client_connect_extended(struct lws_context *context, const char *address,
|
|||
i.ietf_version_or_minus_one = ietf_version_or_minus_one;
|
||||
i.userdata = userdata;
|
||||
|
||||
return lws_client_connect_info(&i);
|
||||
return lws_client_connect_via_info(&i);
|
||||
}
|
||||
/**
|
||||
* lws_client_connect_info() - Connect to another websocket server
|
||||
* DEPRECATED use lws_client_connect_via_info
|
||||
* @context: 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
|
||||
*/
|
||||
|
||||
|
||||
/* deprecated use lws_client_connect_info */
|
||||
LWS_VISIBLE struct lws *
|
||||
lws_client_connect(struct lws_context *context, const char *address,
|
||||
int port, int ssl_connection, const char *path,
|
||||
|
|
|
@ -1617,7 +1617,7 @@ lws_client_connect_extended(struct lws_context *clients, const char *address,
|
|||
void *userdata);
|
||||
|
||||
LWS_VISIBLE LWS_EXTERN struct lws *
|
||||
lws_client_connect_info(struct lws_client_connect_info * ccinfo);
|
||||
lws_client_connect_via_info(struct lws_client_connect_info * ccinfo);
|
||||
|
||||
LWS_VISIBLE LWS_EXTERN const char *
|
||||
lws_canonical_hostname(struct lws_context *context);
|
||||
|
|
|
@ -368,13 +368,13 @@ int main(int argc, char **argv)
|
|||
if (!wsi_dumb && ratelimit_connects(&rl_dumb, 2u)) {
|
||||
lwsl_notice("dumb: connecting\n");
|
||||
i.protocol = protocols[PROTOCOL_DUMB_INCREMENT].name;
|
||||
wsi_dumb = lws_client_connect_info(&i);
|
||||
wsi_dumb = lws_client_connect_via_info(&i);
|
||||
}
|
||||
|
||||
if (!wsi_mirror && ratelimit_connects(&rl_mirror, 2u)) {
|
||||
lwsl_notice("mirror: connecting\n");
|
||||
i.protocol = protocols[PROTOCOL_LWS_MIRROR].name;
|
||||
wsi_mirror = lws_client_connect_info(&i);
|
||||
wsi_mirror = lws_client_connect_via_info(&i);
|
||||
}
|
||||
|
||||
lws_service(context, 500);
|
||||
|
|
|
@ -486,7 +486,7 @@ int main(int argc, char **argv)
|
|||
i.protocol = connect_protocol;
|
||||
i.client_exts = exts;
|
||||
|
||||
wsi = lws_client_connect_info(&i);
|
||||
wsi = lws_client_connect_via_info(&i);
|
||||
if (!wsi) {
|
||||
lwsl_err("Client failed to connect to %s:%u\n",
|
||||
address, port);
|
||||
|
|
Loading…
Add table
Reference in a new issue