How to read what's remaining in a Socket's InputStream after writing in it?
Clash Royale CLAN TAG #URR8PPP How to read what's remaining in a Socket's InputStream after writing in it? I'm trying to read the full content of a socket inputstream that just got closed. If I just try reading it normally works however, I'm constantly trying to write in that socket's output stream in the same time. It looks like writing into it "breaks" the socket's inputstream and makes it impossible to read what's remaining. Take this small example I made to illustrate my problem: @Test public void socketTest() throws Throwable { new Thread(() -> { try { ServerSocket serverSocket = new ServerSocket(5555); while(true) { //keep listening Socket socket = serverSocket.accept(); InputStream in = socket.getInputStream(); System.out.println(in.read()); Thread.sleep(2000); try { ...