When using TCPSockets, can anyone tell me the difference between the .Close and .Disconnect methods? Should they both be used or just one?
Thanks,
Tim
When using TCPSockets, can anyone tell me the difference between the .Close and .Disconnect methods? Should they both be used or just one?
Thanks,
Tim
Close automatically calls Disconnect. Also, the socket will be disconnected and closed when it goes out of scope. So the following all get the job done.
sock.Disconnect
sock.Close
sock.Close
sock = Nil
sock = New TCPSocket
Hi Tim,
Thanks four your response!
I do not want to destroy the socket, I have like 25 pre-created, so i just want to disconnect and close them, then reuse. With that, not necessary to set it to Nil correct?
Thanks Tim,
Tim
A connected TCPSocket holds a reference to itself, thereby keeping itself in scope, until the other side disconnects. The TCPSocket documentation calls this “orphaning” the socket.
Good to know.
Be aware that double closing sockets can lead to a crash: Big Sur ServerSocket Trouble - #7 by Mike_D
If after closing a socket, does it need to be re-instantiated? Or is it just closed and can be used again?
Tim
It can be reused without being re-instantiated.