From e990b127f48882996bc24094cc4fad49d343bfe5 Mon Sep 17 00:00:00 2001 From: marha Date: Sat, 2 Jan 2010 14:58:00 +0000 Subject: Use InitWSA function to intialise winsock. --- libxcb/src/xcb_util.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'libxcb/src/xcb_util.c') diff --git a/libxcb/src/xcb_util.c b/libxcb/src/xcb_util.c index 2d23842d7..2980cb8d0 100644 --- a/libxcb/src/xcb_util.c +++ b/libxcb/src/xcb_util.c @@ -221,6 +221,23 @@ static int _xcb_open_decnet(const char *host, const char *protocol, const unsign } #endif +#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(char *host, char *protocol, const unsigned short port) { int fd = -1; @@ -254,16 +271,8 @@ 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(); - } - } + if (InitWSA()<0) + return -1; #endif snprintf(service, sizeof(service), "%hu", port); -- cgit v1.2.3