From a1e316ddcf7e014b9bd33185f65a56e7fd9817a8 Mon Sep 17 00:00:00 2001 From: "Sergio R. Caprile" Date: Wed, 6 Sep 2023 18:50:33 -0300 Subject: [PATCH] make TCP example work with new TLS API --- examples/tcp/main.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/examples/tcp/main.c b/examples/tcp/main.c index 3889ac62..e60906b6 100644 --- a/examples/tcp/main.c +++ b/examples/tcp/main.c @@ -54,6 +54,10 @@ static void cfn(struct mg_connection *c, int ev, void *ev_data, void *fn_data) { MG_INFO(("CLIENT has been initialized")); } else if (ev == MG_EV_CONNECT) { MG_INFO(("CLIENT connected")); +#if MG_TLS + struct mg_str host = mg_url_host(s_conn); + mg_tls_init(c, host); +#endif *i = 1; // do something } else if (ev == MG_EV_READ) { struct mg_iobuf *r = &c->recv; @@ -85,6 +89,9 @@ static void sfn(struct mg_connection *c, int ev, void *ev_data, void *fn_data) { MG_INFO(("SERVER is listening")); } else if (ev == MG_EV_ACCEPT) { MG_INFO(("SERVER accepted a connection")); +#if MG_TLS + mg_tls_init(c, mg_str("")); +#endif } else if (ev == MG_EV_READ) { struct mg_iobuf *r = &c->recv; MG_INFO(("SERVER got data: %.*s", r->len, r->buf));