Winsock - reconnecting server - error 10061

Hi ! I have a 1 server/1 client TCP winsock MFC app that works generally the way I want it to. The issue is that when the server/or client disconnects I am unable to automate a reconnection on the server side.

The catch is that I can reconnect the server to listen manually with no issues. The main difference between the two is that to reconnect manually, I open a new modal dialog box, input the desired port then press 'OK' which returns to the parent dialog.
Whereas, the automatic reconnect is a method of the parent dialog.

The code for each is practically identical except for this (server side):

Manual (in listen modal dlg):
1
2
3
4
5
6
7
HWND hParent = NULL;
if(m_hWnd != NULL)
{
   hParent = ::GetParent(m_hWnd);
}

WSAAsyncSelect (s, hParent, WM_ASYNC_MSG, FD_READ | FD_WRITE | FD_ACCEPT | FD_CLOSE); //Switch to Non-Blocking mode 


Automatic (part of method in the main dlg):
1
2
3
4
5
6
7
8
HWND hParent = NULL;
if(m_hWnd != NULL)
{
   CWnd *pWnd = GetParent();
   hParent = *pWnd;
}

WSAAsyncSelect (s, hParent, WM_ASYNC_MSG, FD_READ | FD_WRITE | FD_ACCEPT | FD_CLOSE); //Switch to Non-Blocking mode 


One the server side everything looks OK when it reconnects. But when the client attempts to connect to the server it received a connection refused 10061 error msg...

Thanks !!!
Topic archived. No new replies allowed.