From 6aa0f61e15c1410e122096bc781a9443e4017385 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 18 May 2010 23:12:56 +0200 Subject: [PATCH] socket_util: fix setsockopt() argument type on WIN32 In the winsock headers, the setsockopt() argument is declared as "const char *", not "const void *". --- src/socket_util.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/socket_util.c b/src/socket_util.c index 7895d3367..0909765ba 100644 --- a/src/socket_util.c +++ b/src/socket_util.c @@ -111,8 +111,14 @@ socket_bind_listen(int domain, int type, int protocol, return -1; } +#ifdef WIN32 + const char *optval = (const char *)&reuse; +#else + const void *optval = &reuse; +#endif + ret = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, - &reuse, sizeof(reuse)); + optval, sizeof(reuse)); if (ret < 0) { g_set_error(error, listen_quark(), errno, "setsockopt() failed: %s", g_strerror(errno));