Community
Participate
Working Groups
We are doing a FBN with a http client and there is FBs to re initialize when the server cannot be connected. (a little bit strange for http connection as the communication failure would release the protocol stack) After long time test, we found that the socket resource are all consumed as no more connection could be initiated for all the applications in windows 10. I dig a litte bit into the code and I think there should be closeSocket(nSocket) in the below code snippet. Win32SocketInterface::TSocketDescriptor CWin32SocketInterface::openTCPClientConnection(char *pa_acIPAddr, unsigned short pa_nPort){ ....... if(SOCKET_ERROR == connect(nSocket, (struct sockaddr*) &stSockAddr, sizeof(struct sockaddr))) { int nLastError = WSAGetLastError(); LPSTR pacErrorMessage = getErrorMessage(nLastError); DEVLOG_ERROR("CWin32SocketInterface: connect() failed: %d - %s\n", nLastError, pacErrorMessage); LocalFree(pacErrorMessage); closeSocket(nSocket); } else{ nRetVal = nSocket; } .......
besides, I checked the couterpart of bsd socket realization and there is close(socket) at the similar postion.
Hi. Good spot, the socket should be closed there also. One comment, for WinSock the function to close a socket is closesocket (all lower case) https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-closesocket Best regards, Martin
yes, (In reply to Martin Melik-Merkumians from comment #2) > Hi. > > Good spot, the socket should be closed there also. > One comment, for WinSock the function to close a socket is closesocket (all > lower case) > > https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock- > closesocket > > Best regards, > Martin yes, Martin, thanks for the information. Somebody made a function in win32socketinterf.cpp called closeSocket and inside it calls closesocket. :)
New Gerrit change created: https://git.eclipse.org/r/c/4diac/org.eclipse.4diac.forte/+/186579
Gerrit change https://git.eclipse.org/r/c/4diac/org.eclipse.4diac.forte/+/186579 was merged to [2.0.x]. Commit: http://git.eclipse.org/c/4diac/org.eclipse.4diac.forte.git/commit/?id=265fb822d1bf433d1e368e741f1af0dee2356050