TCP connection best practices?

Ask A Question

Login To post a question

I’m currently developing an android real time application (time-sensitive) which requires a local TCP server that can handle 6-10 TCP clients at a time to communicate to each other. As of now, I have a Server service that has 2 threads and an array list. First thread will start a new thread (for listening) and add it to array list if there is a new socket connection accepted, second thread is for maintaining the array list of threads that has active sockets(continuously writing and if it throws an error, it will remove it from the array list).

Considering that the communication will be handled locally (through a router without internet or hotspot)
Questions :

  1. Is continuously writing to the client sockets a good practice (every second) for checking if it still active?

  2. Will it cause problem such as latency, delays, etc., if I also create a service for client that will also continuously write to the server?

  3. Is it okay to keep the connection alive for all of the socket clients (6-10 devices)?

  4. For android server, the maximum number of threads that will be created is 12, is it an overkill for an android phone?

For more info please click here

Have a question or need a custom quote?