| Author |
Software caused connection abort: socket write error
|
coder watson
Greenhorn
Joined: Nov 11, 2008
Posts: 5
|
|
I have TCP/IP based service which is continously 24*7 running on a port. It communicates using XML. when response is < 1023 characters...the client recieves data properly.... but when response is > 1023 characters the client recieves half the response (i.e exactly 1023 chars) and remaining chars are lost...and at the service end it throws exception: Software caused connection abort: socket write error Complete stack trace: java.net.SocketException: Software caused connection abort: socket write error at java.net.SocketOutputStream.socketWrite0(Native Method) at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92) at java.net.SocketOutputStream.write(SocketOutputStream.java:136) at sun.nio.cs.StreamEncoder$CharsetSE.writeBytes(StreamEncoder.java:336) at sun.nio.cs.StreamEncoder$CharsetSE.implWrite(StreamEncoder.java:395) at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:136) at java.io.OutputStreamWriter.write(OutputStreamWriter.java:191) at java.io.BufferedWriter.flushBuffer(BufferedWriter.java:111) at java.io.BufferedWriter.write(BufferedWriter.java:212) at java.io.Writer.write(Writer.java:126) at com.icici.cardvalidator.queryserver.TCPXMLThread.run(TCPXMLThread.jav a:328) java.net.SocketException: Software caused connection abort: socket write error at java.net.SocketOutputStream.socketWrite0(Native Method) at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92) at java.net.SocketOutputStream.write(SocketOutputStream.java:136) at sun.nio.cs.StreamEncoder$CharsetSE.writeBytes(StreamEncoder.java:336) at sun.nio.cs.StreamEncoder$CharsetSE.implWrite(StreamEncoder.java:395) at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:136) at java.io.OutputStreamWriter.write(OutputStreamWriter.java:191) at java.io.BufferedWriter.flushBuffer(BufferedWriter.java:111) at java.io.BufferedWriter.write(BufferedWriter.java:212) at java.io.Writer.write(Writer.java:126) at com.icici.cardvalidator.queryserver.TCPXMLThread.run(TCPXMLThread.jav a:328)
|
 |
Amit Ghorpade
Bartender
Joined: Jun 06, 2007
Posts: 2552
|
|
|
"coder xyz " please check your private messages for an important administrative matter.
|
SCJP, SCWCD.
|Asking Good Questions|
|
 |
coder watson
Greenhorn
Joined: Nov 11, 2008
Posts: 5
|
|
my mistake....have updated the name .... but can nybody help with the prob...
|
 |
Vijay Jeyam
Greenhorn
Joined: Nov 12, 2008
Posts: 15
|
|
Are you reading the connection till you get the end of stream. Or you use a byte[] to read the 1024 char and closr the connection. while (stream.read(byte[]) != -1) is there any place you have somethig like this
|
Never Never Never Give Up...!!!
|
 |
coder watson
Greenhorn
Joined: Nov 11, 2008
Posts: 5
|
|
THis is code i have written in client to read from the inputstream of the server. ************************************************ InputStream toServerinput = socket.getInputStream(); int i; while ((i = toServerinput.read()) != -1) { inps.append((char) i); if (toServerinput.available() == 0) { break; } } ****************************************************
|
 |
Vijay Jeyam
Greenhorn
Joined: Nov 12, 2008
Posts: 15
|
|
The code will be something like this which is to read the iStream completely. // Some input stream where you read data iStream byte[] b = new byte[1024]; while(iStream.read(b) != -1){ /// Do something }
|
 |
coder watson
Greenhorn
Joined: Nov 11, 2008
Posts: 5
|
|
still m able to get only half the packet......thats....8192 chars... but in response there are 62000 chars..... i set byte array.. byte b = new byte[64000]... but only getting...8000 chars or so... need help.....to read full response...
|
 |
Ben Spink
Greenhorn
Joined: Nov 12, 2008
Posts: 5
|
|
|
|
 |
coder watson
Greenhorn
Joined: Nov 11, 2008
Posts: 5
|
|
|
thanks guys.
|
 |
 |
|
|
subject: Software caused connection abort: socket write error
|
|
|