Good socket communication program, from window into the Linux operating system, only with the server exchange a few simple data, newspaper java.net.SocketException broken pipe abnormal, very strange, found a lot on the internet Similar questions include answers, and none seem to solve the problem.
I've been able to discharge some of the possible situations,
1, the connection has never been disconnected;
2, the transaction data quantity is few, does not exist the time-out problem, moreover is the long connection;
3, in the input, the output stream in the synchronization.
4, running on the window for more than 1 years. I've never had a problem like this.
Some of the error messages are as follows:
Java.net.SocketException:Broken Pipe
At Java.net.SocketOutputStream.socketWrite0 (Native method)
At Java.net.SocketOutputStream.socketWrite (socketoutputstream.java:92)
At Java.net.SocketOutputStream.write (socketoutputstream.java:136)
At Java.io.objectoutputstream$blockdataoutputstream.drain (objectoutputstream.java:1639)
At Java.io.objectoutputstream$blockdataoutputstream.flush (objectoutputstream.java:1584)
At Java.io.ObjectOutputStream.reset (objectoutputstream.java:639)
This troubled me for many weeks of the problem, I hope you can get the help of high man, to solve my urgent need!
------Workaround--------------------------------------------------------
Your Long connection
Linux will kick off long connections that are not connected over time
There are settings in Linux
------Workaround--------------------------------------------------------
4, running on the window for more than 1 years. I've never had a problem like this.
I think it's the Linux system, and you take another version of the Linux system and look at it.
The difference between the different is still relatively large
------Workaround--------------------------------------------------------
The network structure under Unix/linux is slightly different from windows, at least in the Java network programming there are some differences (no textual research, but they have encountered the same problem. )
The reason Java.net.SocketException:Broken pipe this anomaly is that you use multiple threads to read/write to a socket channel at the same time (Windows does not have this problem), simply unix/ Linux cannot read and write to a socket channel at the same time. And I've also tried to use synchronization controls to prevent the same socket channel from being read and written, however, only reduced the probability of the exception (is not a problem of synchronization control), send and receive a delay after the addition of the problem does not occur, of course, the application can not tolerate such processing efficiency and performance.
Finally, I switched the entire network traffic to a non-blocking mode with new IO, which is not a problem in single-threaded processing, and it seems that the system throughput is higher than before, but the only remaining problem remains unresolved.
See my question post:
http://community.csdn.net/Expert/topic/5385/5385219.xml?temp=.1896173
------Workaround--------------------------------------------------------
I also encountered the same problem one hours ago, hard to make a program in Windows running normally, on Linux on the broken pipe. But I was single-threaded and the same problem occurred when flush () was abnormal