The problem:
I've got 5 devices (non-computers... industrial devices) acting as TCP Servers. I've written software in C# to use TcpClient to connect to all 5 and then communicate with them.
What happens is that the workers in the plant will unplug a device to charge their cellphone. This breaks the connection to the device. At some point, that station needs to operate, so they unplug their cellphone charger and plug the device back in, and now it can't communicate. This is a well-known problem where if the TCP Server drops the connection, the client can't tell.
Since my software never initiates communication with the devices (it only reacts to incoming data), I can't tell if the connection has been broken.
What I've done, then, is given them a 'reconnect to device X' button on their software.
The problem is that I can't de-reference the TcpClient in my software. I need to reconnect to the TCP Server without losing the reference to the original TcpClient object and I'm having a tough time figuring out how to do that.
Closing the underlying client ( TcpClient.Client.Close() ) followed by a TcpClient.Connect(values) doesn't reconnect.
Is there any way to force a re-connect through a TcpClient without just disposing the initial TcpClient and creating a new one?
Thanks.
I've got 5 devices (non-computers... industrial devices) acting as TCP Servers. I've written software in C# to use TcpClient to connect to all 5 and then communicate with them.
What happens is that the workers in the plant will unplug a device to charge their cellphone. This breaks the connection to the device. At some point, that station needs to operate, so they unplug their cellphone charger and plug the device back in, and now it can't communicate. This is a well-known problem where if the TCP Server drops the connection, the client can't tell.
Since my software never initiates communication with the devices (it only reacts to incoming data), I can't tell if the connection has been broken.
What I've done, then, is given them a 'reconnect to device X' button on their software.
The problem is that I can't de-reference the TcpClient in my software. I need to reconnect to the TCP Server without losing the reference to the original TcpClient object and I'm having a tough time figuring out how to do that.
Closing the underlying client ( TcpClient.Client.Close() ) followed by a TcpClient.Connect(values) doesn't reconnect.
Is there any way to force a re-connect through a TcpClient without just disposing the initial TcpClient and creating a new one?
Thanks.