0

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?

Greelings
  • 4,964
  • 7
  • 34
  • 70
  • 3. Use TCP for mutual client-induced Client<=>Server communication and UDP for Server => Client push messages? – Fildor Jan 18 '17 at 11:45
  • TCP is a peer-to-peer protocol. Once a connection is set up, either host on the connection can send data. Client/server is an application concept, and TCP know nothing about clients or servers. – Ron Maupin Jan 18 '17 at 15:27

0 Answers0