summaryrefslogtreecommitdiff
path: root/protocols/MSN/msn_commands.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/MSN/msn_commands.cpp')
-rw-r--r--protocols/MSN/msn_commands.cpp30
1 files changed, 10 insertions, 20 deletions
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);
}