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?
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.