| 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]
|
 |
 |
|
|
subject: Connection reset error in input.readLine()
|
|
|