Hi,
I need to write a apps using socket connection to a server for an hospital.
The nurse need to receive information on a Android PDA.
I need to find a method to check Permanently if the connection to the server is OK.
I was thinking about a timer whoe's check every second if the socket_Connected was = to True.
My suggestion is to have a look at Erel's b4a bridge source code.
About your last question. You can have a 'isConnected' flag. When false (for e.g. inside a astreams_terminated sub), you can enable a timer trying to connect to your server. Eventually, when your server is up again, a connection will be established, so you will set your 'isConnected' flag to true.
Hi
I follow the idea of mc73 and create a boolean 'IsConnected' and a timer to make the reconnection.
When the server application broken the socket connection I receive an Astreams_terminated event. And it works fine.
But if the network goes down (b.e if I plug out the network cable of my server), I don't receive any event....
When you try to reconnect the socket_connected sub should be triggered and there you should check the 'success' flag of this sub. Doesn't it get triggered? What timeout are you using?
Hi mc73,
The problem is that I don't know when I have to reconnect because I don't receive any event who tell me that the connection is broken when a plug out the network cable....
This is why I asked you to have a look at b4aBridge source. It is a good practice to ping your server every once in a while to check if connectivity is ok. This can be done by a timer. And since you already have a timer, you can ping it from there. You wait for a reply, after pinging, if not arriving in some secs, you can tell that your connections is down