File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Sockets and Internet Protocols and the fly likes Connection reset Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark " Connection reset" Watch " Connection reset" New topic
Author Connection reset

mania mir

Joined: Oct 08, 2013
Posts: 11
I'm new at socket programming and threads. I'd be happy if anyone can help me out with this exception.

Two server sockets are running,
1) Control Server at port 10500, I have no problem in getting result from this server it returns "done#1#end#done#2#end#done#3#end#done#4#end#done#5#end" at line 67.
2) Transfer Server at port 10502, the socket exception occurs at the time of reading result from Transfer server at line 96.

And the Client Socket is running at localhost/10501.

At line 92, I've already checked if there is a client connection and the opening state of ControlServer/TransferServer.
But the inputstream (_inFromTransferServer) for reading the result from TransferServer is not ready. I wonder if that causes this exception?

That's the main():

That's the thread class:

That's the stacktrace of the exception: Connection reset
at java:196)
at java:122)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.j ava:283)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.ja va:325)
at 77)
at ava:184)
at 4)
at 05)
at 9)
at (
at ava:450)
at ava:450)
at$ .java:1760)
Vivek SharmaJi
Ranch Hand

Joined: Dec 09, 2012
Posts: 38

There may be following issues.

The other end has deliberately reset the connection, in a way which I will not document here. It is rare, and generally incorrect, for application software to do this, but it is not unknown for commercial software.

More commonly, it is caused by writing to a connection that the other end has already closed normally. In other words an application protocol error.

In Windows, 'software caused connection abort', which is not the same as 'connection reset', is caused by network problems sending from your end.

Dennis Grimbergen
Ranch Hand

Joined: Nov 04, 2009
Posts: 159

Shouldn't the client connect to the same port as the serversocket is listening on?

I agree. Here's the link:
subject: Connection reset
It's not a secret anymore!