Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Created January 12, 2022 09:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save velotiotech/69359f48f80cbc4b2d3c050b23b43259 to your computer and use it in GitHub Desktop.
Save velotiotech/69359f48f80cbc4b2d3c050b23b43259 to your computer and use it in GitHub Desktop.
static void connect_client(struct lws_sorted_usec_list *sul)
{
struct vhd_minimal_client_echo *vhd =
lws_container_of(sul, struct vhd_minimal_client_echo, sul);
struct lws_client_connect_info i;
char host[128];
lws_snprintf(host, sizeof(host), "%s:%u", *vhd->ads, *vhd->port);
memset(&i, 0, sizeof(i));
i.context = vhd->context;
//i.port = *vhd->port;
i.port = *vhd->port;
i.address = *vhd->ads;
i.path = *vhd->url;
i.host = host;
i.origin = host;
i.ssl_connection = LCCSCF_USE_SSL | LCCSCF_ALLOW_SELFSIGNED | LCCSCF_SKIP_SERVER_CERT_HOSTNAME_CHECK | LCCSCF_PIPELINE;
//i.ssl_connection = 0;
if ((*vhd->options) & 2)
i.ssl_connection |= LCCSCF_USE_SSL;
i.vhost = vhd->vhost;
i.iface = *vhd->iface;
//i.protocol = ;
i.pwsi = &vhd->client_wsi;
//lwsl_user("connecting to %s:%d/%s\n", i.address, i.port, i.path);
log_message(LOG_INFO,ws_applogic.pamh,"About to create connection %s",host);
//return !lws_client_connect_via_info(&i);
if (!lws_client_connect_via_info(&i))
lws_sul_schedule(vhd->context, 0, &vhd->sul,
connect_client, 10 * LWS_US_PER_SEC);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment