diff options
Diffstat (limited to 'libxcb/src/xcb_util.c')
-rw-r--r-- | libxcb/src/xcb_util.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/libxcb/src/xcb_util.c b/libxcb/src/xcb_util.c index c3cbfa6c1..2d23842d7 100644 --- a/libxcb/src/xcb_util.c +++ b/libxcb/src/xcb_util.c @@ -47,6 +47,10 @@ #include "xcbext.h" #include "xcbint.h" +#ifdef _MSC_VER +#define close(fd) closesocket(fd) +#endif + static const int error_connection = 1; int xcb_popcount(uint32_t mask) @@ -249,6 +253,19 @@ static int _xcb_open_tcp(char *host, char *protocol, const unsigned short port) } #endif +#ifdef WIN32 + { + static WSADATA wsadata; + + if (!wsadata.wVersion) + { + if (WSAStartup(0x0202, &wsadata)) + return -1; + ptw32_processInitialize(); + } + } +#endif + snprintf(service, sizeof(service), "%hu", port); if(getaddrinfo(host, service, &hints, &results)) /* FIXME: use gai_strerror, and fill in error connection */ @@ -258,7 +275,7 @@ static int _xcb_open_tcp(char *host, char *protocol, const unsigned short port) { fd = socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol); if(fd >= 0) { - int on = 1; + char on = 1; setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on)); setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof(on)); |