diff options
Diffstat (limited to 'libxcb/src/xcb_util.c')
-rw-r--r-- | libxcb/src/xcb_util.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/libxcb/src/xcb_util.c b/libxcb/src/xcb_util.c index f8d381d3b..3449cb2a4 100644 --- a/libxcb/src/xcb_util.c +++ b/libxcb/src/xcb_util.c @@ -60,6 +60,13 @@ # include <sys/stat.h> #endif +#ifdef _MSC_VER +#ifdef close +#undef close +#endif +#define close(fd) closesocket(fd) +#endif + int xcb_popcount(uint32_t mask) { uint32_t y; @@ -272,7 +279,7 @@ static int _xcb_socket(int family, int type, int proto) static int _xcb_do_connect(int fd, const struct sockaddr* addr, int addrlen) { - int on = 1; + char on = 1; if(fd < 0) return -1; @@ -283,6 +290,23 @@ static int _xcb_do_connect(int fd, const struct sockaddr* addr, int addrlen) { return connect(fd, addr, addrlen); } +#ifdef WIN32 +int InitWSA(void) +{ + static WSADATA wsadata; + + if (!wsadata.wVersion) + { + ptw32_processInitialize(); + if (WSAStartup(0x0202, &wsadata)) + return -1; + } + return 0; +} +#else +#define InitWSA() +#endif + static int _xcb_open_tcp(const char *host, char *protocol, const unsigned short port) { int fd = -1; @@ -322,6 +346,11 @@ static int _xcb_open_tcp(const char *host, char *protocol, const unsigned short } #endif +#ifdef WIN32 + if (InitWSA()<0) + return -1; +#endif + snprintf(service, sizeof(service), "%hu", port); if(getaddrinfo(host, service, &hints, &results)) /* FIXME: use gai_strerror, and fill in error connection */ |