# In the case of my communication program with PC and server using TCP/IP, I don't know the cause of re-connection error as follows.
1. One TCP/IP Server type A has a program which use 2 ports 502, 3999 -
502 port used for receiving data from PC, 3999 port used for sending data to same PC
2. In PC program, it is using VC++ using winsocks library, countpart program of the server is onto the Linux.
3. Of the Linux server, 3999 PORT is setting by keep alive TCP/IP options.
4. The problem is that when the server close socket using 502 anytime, and I verified the Fin/Fin Ack signals between two servers - PC and Linux server by checking in the wireshark.
5. Another program of PC cannot connect the 502 port - which is already closed - with same ip address to the server .
5. Even whatever I can do anything, I cannot re-connect to the server by same ip address and 502 port.
6. The WSAGetLastErrorcode = WSAEISCONN (10056)
7. The sample is that as follows.
int result= inet_pton(AF_INET, "192.168.0.222", /*server address */ ,ToServer.sin_addr);
ToServer.sin_port = htons(502);
int ret_code = connect(ClientSocket, (struct sockaddr *)&ToServer, sizeof(ToServer));
if (ret_code != 0)
{
Sleep(10);
retcnt++;
ret_code = WSAGetLastError();
if (ret_code == WSAEISCONN)
{
AfxMessageBox(_T("Connection Failed. Already binding with another process."));
goto EXIT;
...
8. Finally, the question is :
One server using two ports close only one TCP port, another foreign application cannot connect the closed same port
Where is the missing points?
Thank you advancely,
What I have tried:
I wasted 2 months long time to solve this problem.