I am using Windows sockets and find that there is no way at all to reliably detect a TCP/IP connection that has been lost by a GC-100 that has been powered down and then powered up again (or cable disconnected/connected briefly), also called ungraceful disconnect.
The Socket's Connected property is useless, Poll() does not detect it and Send() does not fail. Netstat reports ESTABLISHED.
I know this is standard TCP/IP and one must use their own (heartbeat) protocol to ensure a reliable 'always connected' connection.
Since this is a COM port, I cannot send a test message and expect a reply. The device might be sleeping, etc.
However, I am now listening to a Keypad on the COM port and I need to keep the connection open (as opposed to closing it after sending).
My workaround now is:
Every 5 minutes, assume the connection has been lost and reconnect (Wasting resources - and possibly reconnect just as a key on the keypad is pressed).
-OR- Every 5 minutes, check the connection to the port 4998 and if still OK, assume port 4999 and 5000 are OK (Not 100% reliable).
Is there a Special string I can send to the ports 4999/5000 that is detected by the GC-100 and replied to (and not forwarded to the COM port) ?
Can I force the GC-100 (send message on port 4998) to test the ports 4999/5000 by sending a message to the client (me).