Android : How can the server call the client back after a disconnection?

67 Views Asked by At

I have 3 devices android (1 server and 2 clients) connected via TCP. Knowing that sometimes the server uses the open socket to contact the client, how can I manage the disconnections?

Indeed, in case of a short disconnection, only the client can restore the connection. The server can't send a message to the client anymore and has to wait for the client's call. Right?

So, I think I have 2 options:

  1. Force the client to maintain the contact with the server, sending an "are you there" message every second to him. Thereby, if a disconnection occurs, it will restore the connection as soon as possible.

  2. Use a peer to peer structure. Both (client and server) can "call" the other when he wants.

While the first solution seems heavier for the network, and the second more complicated to set up and maintain. What do you recommend?

0

There are 0 best solutions below