From 8549e48fbb8520027d4d8ba74b6f12f3042faebc Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 27 May 2012 21:30:30 +0000 Subject: ipv6 sync git-svn-id: http://svn.miranda-ng.org/main/trunk@205 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/MSN/msn_commands.cpp | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) (limited to 'protocols/MSN/msn_commands.cpp') diff --git a/protocols/MSN/msn_commands.cpp b/protocols/MSN/msn_commands.cpp index 04d2ad7981..a85ff46fe4 100644 --- a/protocols/MSN/msn_commands.cpp +++ b/protocols/MSN/msn_commands.cpp @@ -30,30 +30,20 @@ void MSN_ConnectionProc(HANDLE hNewConnection, DWORD /* dwRemoteIP */, void* ext proto->MSN_DebugLog("File transfer connection accepted"); - WORD localPort = 0; - SOCKET s = MSN_CallService(MS_NETLIB_GETSOCKET, (WPARAM)hNewConnection, 0); - if (s != INVALID_SOCKET) + NETLIBCONNINFO connInfo = { sizeof(connInfo) }; + CallService(MS_NETLIB_GETCONNECTIONINFO, (WPARAM)hNewConnection, (LPARAM)&connInfo); + + ThreadData* T = proto->MSN_GetThreadByPort(connInfo.wPort); + if (T != NULL && T->s == NULL) { - SOCKADDR_IN saddr; - int len = sizeof(saddr); - if (getsockname(s, (SOCKADDR*)&saddr, &len) != SOCKET_ERROR) - localPort = ntohs(saddr.sin_port); + T->s = hNewConnection; + ReleaseSemaphore(T->hWaitEvent, 1, NULL); } - - if (localPort != 0) + else { - ThreadData* T = proto->MSN_GetThreadByPort(localPort); - if (T != NULL && T->s == NULL) - { - T->s = hNewConnection; - ReleaseSemaphore(T->hWaitEvent, 1, NULL); - return; - } - proto->MSN_DebugLog("There's no registered file transfers for incoming port #%d, connection closed", localPort); + proto->MSN_DebugLog("There's no registered file transfers for incoming port #%u, connection closed", connInfo.wPort); + Netlib_CloseHandle(hNewConnection); } - else proto->MSN_DebugLog("Unable to determine the local port, file server connection closed."); - - Netlib_CloseHandle(hNewConnection); } -- cgit v1.2.3