aspose file tools
The moose likes Sockets and Internet Protocols and the fly likes Connection reset error in input.readLine() Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Reply Bookmark "Connection reset error in input.readLine() " Watch "Connection reset error in input.readLine() " New topic
Author

Connection reset error in input.readLine()

Sam Gehouse
Ranch Hand

Joined: Jul 21, 2003
Posts: 281
I am getting connection reset exception in line input.readLine() as shown below. Any help will be appreciated.

Code is shown below

Socket socket = new Socket();
socket.connect(new InetSocketAddress("myMachine", 4444), 0);

DataOutputStream output = new DataOutputStream(outputStream);
DataInputStream input = new DataInputStream(socket.getInputStream());
String request = "abcd" // abcd is the string passed to server
output.write(request.getBytes());

String responseLine;
while (true) {
responseLine = input.readLine();
os.println(responseLine);
}

On input.readLine() I get the exception as shown below:

java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:136)
at java.net.SocketInputStream.read(SocketInputStream.java:208)
at java.io.DataInputStream.readLine(DataInputStream.java:527)
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8262

You are only showing us half the picture, but does your server code happen to close the socket (rather than the input stream) when it is done reading the request?


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Connection reset error in input.readLine()
 
Similar Threads
simple socket programming
problem with connect with URL
How to write to the servlet with standalone application
Please identify error
java.net.SocketException: Connection reset due to serialVersionUID