I have a program running on a server (Server A) that listens on one port for external connection (from an external server, B) and then listens on another port for internal connection on one server (server A), then it transfers data from the internal to the external connection and back.
I want to know if there is a way to detect that the external client has been disconnected. I just need one external connection at a time, but I would like to be able to accept a new one if the external client reboots or something like that.
This socket level stuff is completely insignificant for me, so if there is a better way around this, Iām all ears. One of the conditions is that the client running on server B must be the initiator of the connection, and the connection should work as long as possible.
public void handleConnection() { System.out.println("Waiting for client message..."); try { SSLSocket extSocket = (SSLSocket) this.externalServerSocket.accept(); ObjectInputStream externalOis = new ObjectInputStream(extSocket.getInputStream()); ObjectOutputStream externalOos = new ObjectOutputStream(extSocket.getOutputStream()); System.out.println("Client connection establisthed");
source share