]> git.meshlink.io Git - meshlink/commitdiff
Call WSAStartup() so that sockets work on Windows.
authorGuus Sliepen <guus@meshlink.io>
Sun, 25 May 2014 14:26:04 +0000 (16:26 +0200)
committerGuus Sliepen <guus@meshlink.io>
Sun, 25 May 2014 14:26:04 +0000 (16:26 +0200)
src/meshlink.c

index 21838ab7d34b919251a0857c5863904020b35030..cd5b5642538a97ef441995bba9dca5c26e634e99 100644 (file)
@@ -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) {