I'm using the Synapse library with Lazarus and I'm trying to switch a TCPBlockSocket
connection between two different IP addresses.
I create the Socket connection with:
mySocket:=TTCPBlockSocket.Create
I then connect to the first IP address with:
mySocket.Connect(firstIPaddress,portNumber);
This works fine, but if I try to switch to the second IP address with
mySocket.Connect(secondIPaddress,portNumber);
any data I send with mySocket.SendString()
is still sent to firstIPaddress
.
I have tried .Destroy
ing mySocket
and recreating it but I get crashes (I check if mySocket
is assigned and if it is do a .Destory
before recreating the TCPBlockSocket
object - but that seems a bit severe anyway.
Is there a correct way to disconnect and then reconnect an exiting TCPBlockSocket
to a different IP address?
And is there an easy way to test if a TCPBLockSocket
has an active and working connection?