Roger Alcindor
asked on
IdTCPClient1->Disconnect(); not working
I have written a TCP client application using Indy 10 components in Embarcadero XE8 C++ Builder enterprise version.
The client connects to a server and exchanges some data with it and that works as expected the first time after the application is run.
I then close the connection by calling IdTCPClient1->Disconnect() ;
Subsequent attempts to connect to the server fail giving an error "Already connected".
Even adding code to test for connection status (shown below), does not work.
Any ideas please ?
if(IdTCPClient1->Connected ())
IdTCPClient1->Disconnect() ;
IdTCPClient1->Connect(); // still gives an error
The client connects to a server and exchanges some data with it and that works as expected the first time after the application is run.
I then close the connection by calling IdTCPClient1->Disconnect()
Subsequent attempts to connect to the server fail giving an error "Already connected".
Even adding code to test for connection status (shown below), does not work.
Any ideas please ?
if(IdTCPClient1->Connected
IdTCPClient1->Disconnect()
IdTCPClient1->Connect(); // still gives an error
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you should delete the instance if you created it with 'new'. generally the destructor should call FreeInstance method.
note, a tcp client instance not necessarily must be created on the heap with new. you also could have it as a non-pointer member in your own class. then of Course the instance must not be deleted but will be freed with the destructor of your class.
Sara
note, a tcp client instance not necessarily must be created on the heap with new. you also could have it as a non-pointer member in your own class. then of Course the instance must not be deleted but will be freed with the destructor of your class.
Sara
ASKER