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 Why is my connection reset on this test program? 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 "Why is my connection reset on this test program?" Watch "Why is my connection reset on this test program?" New topic

Why is my connection reset on this test program?

Colm Dickson
Ranch Hand

Joined: Apr 04, 2009
Posts: 89
Hi all.

I'm conducting a small client/server's supposed to emulate a server that can handle multiple clients that connect to the server on the local machine. Currently I'm just sending the messages but have not set up and responses to come back from the server yet. I'm just checking that the name passed to the server can be looked up in the hashmap table initialised and filled by the server.

For this test, I'm just sending a few messages, one after the other, rather than using any gui / command line option to post the messages.

After these messages are sent, my program causes a 'connection reset' to be thrown ,accoridng to the stack trace.

The BufferedReader that I have on the server waiting for these messages from the client seems to be ok as it is always reading as long as the reader is not null.

I will post the code below. Can anyone help me with what is the exact cause of this socket error please?


Test Server code

Now the Runnable class to be run as a thread in the server in respinse to each client connection

So here is my client

I have a test class for the server (below). I then start the server running and then the client

What I want is for my program to remain inside the while loop simply waiting for a new client message to be sent but as it is, it reads the messages sent and then an exception is thrown. I thought it was best to post my code. Hope someone can shed some light on this please as I really want to get my head around sockets...the basics at least.

Many thanks,


I agree. Here's the link:
subject: Why is my connection reset on this test program?
It's not a secret anymore!