Using java socket library and what I see is that when the server accepts the tcp connection but not read data from the buffer and in the meantime our client keep pumping heavy data, client side heap size grows to max available and crushes the client application. Is there anyway I can limit the socket buffer size or whatever using that heap and if it is violated, connection is killed? This way client can detect client detect the connection is gone and
Client Side;
this.socket = new Socket(server, port);
this.socket.setKeepAlive(true);
this.outwriter = new OutputStreamWriter(this.socket.getOutputStream());
this.outwriter.write(o.toString());
Server Side;
conn = serverSocket.accept();