Hi,
I am using a socket to send data between a device and my phone.
I have everything working except when the connection is lost.
My phone/app makes the connection to my TCP device and the commands and data is going though fine.
But then on my TCP device I pull the LAN cable out. The connection should now be lost, however the app thinks its still connected. The AStreams_Terminated and AStreams_Error does not get triggered when the connection is lost.
If I then send a command to my TCP device, the app sends the data but does not get anywhere.
The only way I can work out if the conneciton is alive or not is to start a timer when I send the data.
In the timer I am making it count to 5 and if the value gets to 5 before getting a reply from my TCP device then I am closing the connection manually. The AStreams_Terminated sub then activates since the connection is now completly lost.
In the AStreams_Terminated sub I am then trying to connect to my TCP device again.
In VB6.0 you can use the Winsock connection state and use it in a timer to check the state of the connection. However I can't seem to find a way to detect if the connection is still alive or not without polling the TCP device.
I don't mind polling the panel to see if it's there but if the customer is using the app on 3G/4G and the app is running in the background I don't want to keep pinging the TCP device just to check it's status as it will start using the customers data on there plan. (which I don't care, but I am sure the customer will)
The thing is that I want the connection to remain open in the background even when the app is not showing on the screen and as soon as the connection is dropped I want to then connect to the TCP device again and if it fails then I want to then display a notification on the screen telling the customer the connection is lost.
Anyone know a way to detect if the Socket is still open without polling the TCP device and waiting for a reply ?
I am using a socket to send data between a device and my phone.
I have everything working except when the connection is lost.
My phone/app makes the connection to my TCP device and the commands and data is going though fine.
But then on my TCP device I pull the LAN cable out. The connection should now be lost, however the app thinks its still connected. The AStreams_Terminated and AStreams_Error does not get triggered when the connection is lost.
If I then send a command to my TCP device, the app sends the data but does not get anywhere.
The only way I can work out if the conneciton is alive or not is to start a timer when I send the data.
In the timer I am making it count to 5 and if the value gets to 5 before getting a reply from my TCP device then I am closing the connection manually. The AStreams_Terminated sub then activates since the connection is now completly lost.
In the AStreams_Terminated sub I am then trying to connect to my TCP device again.
In VB6.0 you can use the Winsock connection state and use it in a timer to check the state of the connection. However I can't seem to find a way to detect if the connection is still alive or not without polling the TCP device.
I don't mind polling the panel to see if it's there but if the customer is using the app on 3G/4G and the app is running in the background I don't want to keep pinging the TCP device just to check it's status as it will start using the customers data on there plan. (which I don't care, but I am sure the customer will)
The thing is that I want the connection to remain open in the background even when the app is not showing on the screen and as soon as the connection is dropped I want to then connect to the TCP device again and if it fails then I want to then display a notification on the screen telling the customer the connection is lost.
Anyone know a way to detect if the Socket is still open without polling the TCP device and waiting for a reply ?