I am creating a java client/server application over TCP where we have two sockets:
I have created in the Server two ServerSockets in order to create Socket One and Two
by accepting the ServerSockets.
At first the client sends some bytes through the first Socket
so that it can tell the Server which file it needs.
Then the Server through the second socket sends the file to the client.
After the client receives the file tries to send back to the server a Transfer Done Message.
There I get the Exception for the closed socket.
However I never close the socket up until now.
I only close the buffer which sents the file.
Even if I try to open again the socketInputStream after I sent the file the error is still the same.
Also if I do not close the buffer which sents the file, the client does not get the file.
Server Exception
Error in Return Message - java.net.SocketException: socket closed
Client Exception
Server response - java.net.SocketException: Software caused connection abort: socket write error
What am I doing wrong?
The SocketException is an exception in Java that is thrown to indicate that an error was encountered while creating or accessing a Socket. Since the SocketException is a checked exception, it either needs to be thrown or surrounded by a try-catch block in code.
java.net.SocketException: Connection reset This SocketException occurs on the server-side when the client closed the socket connection before the response could be returned over the socket. For example, by quitting the browser before the response was retrieved. Connection reset simply means that a TCP RST was received.
Summary. If you run into the “ERR_CONNECTION_RESET” error, it means that your browser can't establish a connection to the remote server. In most cases, it's due to a misconfiguration in your internet settings or something else that's blocking the connection.
A 'Socket closed' exception means that the application that caught the exception closed the socket and then kept trying to use it. You may be unaware that closing the input or output stream of a socket closes the other stream and the socket as well. For 'software caused connection abort' see the duplicate link.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With