I have the following code:
public class StartSocket{
serverSocket = new ServerSocket(listenPort);
while (listening)
{
new ServerThread(serverSocket.accept()).start();
}
}
The ServerThread
is used to communicate with the client. It sends heartbeat messages every 4 seconds. When I have bandwidth issues the client attempts to reestablish the connection. As such the ServerThread
is continually being opened. This causes an overload on the server.
How do I manage the re-connection attempts by the client?