Update use of error_connection under WIN32 to _xcb_conn_ret_error()
[free-sw/xcb/libxcb] / src / xcb_util.c
index a55df16..7173db3 100644 (file)
 #include <stddef.h>
 #include <unistd.h>
 #include <string.h>
-#include <arpa/inet.h>
 
 #ifdef _WIN32
 #include "xcb_windefs.h"
 #else
+#include <arpa/inet.h>
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <netinet/in.h>
@@ -426,11 +426,22 @@ xcb_connection_t *xcb_connect_to_display_with_auth_info(const char *displayname,
     if(!parsed) {
         c = _xcb_conn_ret_error(XCB_CONN_CLOSED_PARSE_ERR);
         goto out;
-    } else
+    } else {
+#ifdef _WIN32
+        WSADATA wsaData;
+        if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) {
+            c = _xcb_conn_ret_error(XCB_CONN_ERROR);
+            goto out;
+        }
+#endif
         fd = _xcb_open(host, protocol, display);
+    }
 
     if(fd == -1) {
         c = _xcb_conn_ret_error(XCB_CONN_ERROR);
+#ifdef _WIN32
+        WSACleanup();
+#endif
         goto out;
     }