Code: Select all
sock_cl->Connect(addr_server,addr_client,false);
Trying to correct this error I found a lot of strange things:
This is the function that close the connection with the server:
Code: Select all
void ClientTCPFrm::DisconnectClick(wxCommandEvent& event)
{
sock_cl->Close();
}
But if in the same place I put sock_cl->IsDisconnect(); that returns true!!!
So at the same time for Ok() the client is connected to a server but for IsDisconnect() that's not true ... very confusing
I tried to destroy the socket and rebuild it after the connection is closed:
Code: Select all
void ClientTCPFrm::DisconnectClick(wxCommandEvent& event)
{
sock_cl->Close();
sock_cl->Destroy();
sock_cl = new wxSocketClient();
sock_cl->SetEventHandler(*this, ID_CLIENT);
sock_cl->SetNotify(wxSOCKET_CONNECTION_FLAG | wxSOCKET_INPUT_FLAG | wxSOCKET_LOST_FLAG);
sock_cl->Notify(true);
}
I tried to save the socket state before the first connection and then restoring it after the disconnection like this:
Code: Select all
...
sock_cl->SaveState()
sock_cl->Connect(addr_server,addr_client,false);
...
void ClientTCPFrm::DisconnectClick(wxCommandEvent& event)
{
sock_cl->Close();
sock_cl->RestoreState();
}
I looked for errors with sock_cl->Error(); after sock_cl->Connect(addr_server,addr_client,false); and after
sock_cl->Close();, but in both cases it returns false.
Is it possible that it's a bug, that when it close the connection is closed the port binded to the client is not made available again?
Please help me beacuse this thing is driving me mad ^^'