From ba0b00d71dc0296ac25fb356c5a29604f4b45776 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 11 Apr 2015 18:02:05 +0000 Subject: no need to bind unopened socket git-svn-id: http://svn.miranda-ng.org/main/trunk@12770 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/netlib/netlibbind.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/modules') diff --git a/src/modules/netlib/netlibbind.cpp b/src/modules/netlib/netlibbind.cpp index e939fc82c1..699799dd17 100644 --- a/src/modules/netlib/netlibbind.cpp +++ b/src/modules/netlib/netlibbind.cpp @@ -229,7 +229,8 @@ INT_PTR NetlibBindPort(WPARAM wParam, LPARAM lParam) sin.sin_port = htons(nlb->wPort); sin6.sin6_port = htons(nlb->wPort); } - + + if (nlbp->s != INVALID_SOCKET) if (bind(nlbp->s, (PSOCKADDR)&sin, sizeof(sin)) == 0) { SOCKADDR_IN sin = { 0 }; int len = sizeof(sin); @@ -238,8 +239,9 @@ INT_PTR NetlibBindPort(WPARAM wParam, LPARAM lParam) foundPort = 1; } - if (bind(nlbp->s6, (PSOCKADDR)&sin6, sizeof(sin6)) == 0) - foundPort = 1; + if (nlbp->s6 != INVALID_SOCKET) + if (bind(nlbp->s6, (PSOCKADDR)&sin6, sizeof(sin6)) == 0) + foundPort = 1; } if (!foundPort) { NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "bind", WSAGetLastError()); -- cgit v1.2.3