This is basically the picture: I have a server and a client (running through localhost). The server creates clientthread for each connection. this new thread is blocked while reading, waiting for messages from the client. Optionally, I can deactivate the server through the GUI, which sends (from the main thread) to "disconnect" to the client, and then closes the output stream to wake up a blocked client run, which, in turn, ends with closing the socket (I believe this is closing not necessary after closing the output stream, but in any case).
Client side: After a connection request, it resets 10 seconds, writes a disconnect message, and reads the char response to char.
Problem:
After the server is deactivated during this 10-second client timeout, the client correctly reads the disconnect message from the server. However, if I just add a dummy print for each char read (inside the while loop), the result of the final read changes. Sometimes he will consider the server “disconnected” correctly, sometimes he will read “disco” or a similar variation and throw this exception:
"Java exception:" Software caused connection abort: recv failed "
Any suggestions as to why adding multiple prints creates this result? I assume that a closed outlet at the other end will not affect reading the message. Other topics that I found about recv errors, timeouts mentioned, which I assume should not happen when using localhost?
source
share