From ede1a2bcd371937eda4d6b2ed1f28b2935a0054c Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Sun, 25 May 2014 16:26:04 +0200 Subject: [PATCH] Call WSAStartup() so that sockets work on Windows. --- src/meshlink.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/meshlink.c b/src/meshlink.c index 21838ab7..cd5b5642 100644 --- a/src/meshlink.c +++ b/src/meshlink.c @@ -797,6 +797,11 @@ meshlink_handle_t *meshlink_open(const char *confbase, const char *name) { if(!read_server_config(mesh)) return meshlink_close(mesh), NULL; +#ifdef HAVE_MINGW + struct WSAData wsa_state; + WSAStartup(MAKEWORD(2, 2), &wsa_state); +#endif + // Setup up everything // TODO: we should not open listening sockets yet @@ -852,6 +857,10 @@ void meshlink_close(meshlink_handle_t *mesh) { exit_configuration(&mesh->config); event_loop_exit(&mesh->loop); + +#ifdef HAVE_MINGW + WSACleanup(); +#endif } void meshlink_set_receive_cb(meshlink_handle_t *mesh, meshlink_receive_cb_t cb) { -- 2.39.2