What is the correct way to close or reset a TcpClient connection? We have software that communicates with the equipment, but sometimes something goes wrong, and we no longer communicate with it until we restart the software.
I tried to force TcpClient.Close () and even set it to null, but this does not work. Only a complete restart of the software is performed.
Suggestions?
I cannot use the using keyword because TpcClient is defined in only one place, but is used throughout the library. (And there is only one connection at any given time)
This is a library that handles communication. The software itself can call the ResetConnection () method of the Controller class (which is hardware).
Currently it looks like
if (tcpClient != null) { tcpClient.Close(); tcpClient = null; }
Now from what I read here, I have to use tcpClient.Dispose () instead of "= null"
I will give this attempt and see if it matters.
TimothyP Jan 08 '09 at 17:55 2009-01-08 17:55
source share