From cb1882f72e8c6e2cfab123e48c5ae2a05bcbd0ec Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Tue, 6 Jun 2017 09:55:59 +0200 Subject: [PATCH] webservices: Set SO_REUSEADDR on listener sockets. Signed-off-by: Hans Leidekker Signed-off-by: Alexandre Julliard --- dlls/webservices/listener.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dlls/webservices/listener.c b/dlls/webservices/listener.c index 5d6d1a82f26..af3978384a3 100644 --- a/dlls/webservices/listener.c +++ b/dlls/webservices/listener.c @@ -315,7 +315,7 @@ static HRESULT open_listener_tcp( struct listener *listener, const WS_STRING *ur { struct sockaddr_storage storage; struct sockaddr *addr = (struct sockaddr *)&storage; - int addr_len; + int addr_len, on = 1; WS_URL_SCHEME_TYPE scheme; WCHAR *host; USHORT port; @@ -337,6 +337,13 @@ static HRESULT open_listener_tcp( struct listener *listener, const WS_STRING *ur if ((listener->u.tcp.socket = socket( addr->sa_family, SOCK_STREAM, 0 )) == -1) return HRESULT_FROM_WIN32( WSAGetLastError() ); + if (setsockopt( listener->u.tcp.socket, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on) ) < 0) + { + closesocket( listener->u.tcp.socket ); + listener->u.tcp.socket = -1; + return HRESULT_FROM_WIN32( WSAGetLastError() ); + } + if (bind( listener->u.tcp.socket, addr, addr_len ) < 0) { closesocket( listener->u.tcp.socket );