SocketException:Broken Pipe/Connection reset problem
807603Jan 7 2008 — edited Jan 12 2008i am writing a simple client in java that interacts with a perl server. I
put an Int into a bytebuffer,
flip it,
change the order, then
write the Int to a data output stream and
flush it.
My perl server receives 4 bytes, unpacks them as an integer, and all is well. This method works perfectly fine, every time, except when the size of the integer approaches the limit of what an integer is in java, 2**31-1 or 2147483647. When i try to send 2147483647over the socket, about 1/3rd of the time it works, the rest of the time i get either
java.net.SocketException: Connection reset
(on my x86 workstation)
or
java.net.SocketException: Broken pipe
(on my x86 CD thinkpad)
depending on which x86 javac 1.6.0_03 machine i try to run it on.
I really don't know if i'm getting this error on the perl or java side of the transaction. i am using .setKeepAlive(true) on the java side. I am using tcp.
I can't understand why the error rate goes up depending on the contents of the 4-byte packages. A 4 byte integer is always a 4 byte integer regardless of what the actual value is? right? The way i have the client set up works pretty much 100% of the time with all Ints from 0-214748364.
If anyone has any ideas, i'd appreciate them.