Java错误 - 软件导致连接中止:recv失败 [英] Java error - Software caused connection abort: recv failed
问题描述
完整错误是:
java.net.SocketException: Software caused connection abort: recv failed
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:168)
at java.net.SocketInputStream.read(SocketInputStream.java:121)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:283)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:325)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177)
at java.io.InputStreamReader.read(InputStreamReader.java:184)
at java.io.BufferedReader.fill(BufferedReader.java:154)
at java.io.BufferedReader.readLine(BufferedReader.java:317)
at java.io.BufferedReader.readLine(BufferedReader.java:382)
at chat.run(chat.java:76)
at java.lang.Thread.run(Thread.java:722)
在chat.run(chat.java:76)是这一行:
"at chat.run(chat.java:76)" is this line:
System.out.println("[_in_"+(line=ins.readLine())+"_]");
行为字符串且ins为BufferedReader
line being a string and ins being a BufferedReader
ins = new BufferedReader(new InputStreamReader(_sock.getInputStream()));
_sock is
Socket _sock = null;
_sock = serv_sock.accept();
这发生在我的服务器java而不是我的客户端java ...
此外,这种情况发生在我不发送任何东西一段时间
This happends on my Server java and not on my client java... Also, this happends when I dont send anything for a little while
-----编辑------
-----EDIT------
我再试一次;
首先,它做了40分钟无所事事它仍然有效,
然后我又等了40分钟,这次它没有用。
I tried it again; First it went 40 minutes of doing nothing and it still worked, then I waited 40 minutes again and this time it didn't work.
它似乎有点随机..
我无法弄清楚是什么导致它。
It seems to be kind of random.. I can't figure out what's causing it.
我的文件是
* [ client.java],[chat.java],[vlc.java]
* [server.java],[chat.java],[vlc.java]
The files I have are * [client.java], [chat.java], [vlc.java] * [server.java], [chat.java], [vlc.java]
vlc文件在两者中是相同的虽然聊天是不同的
(因为我还没有在客户端和服务器上完成线程)
the vlc files are the same in both although chat is different (since I havn't done Threads in both client and server yet)
这里是代码;
SERVER
server.java: pastebin.com/GH8ShcGp
chat.java : pastebin.com/iaL23kSb
vlc.java : pastebin.com/9kyrbh5q
CLIENT
client.java: pastebin.com/HDK450Jg
chat.java : pastebin.com/CfHrEUkE
vlc.java : pastebin.com/SfZgYy58
< hr>
我认为这是一个窗口/网络的事情。
有人请求帮我解决这个问题?
I think it's a window/network thing. Someone who please can help me fix this??
推荐答案
我无法解决您的确切问题我自己的计算机使用你的代码和localhost-connections,但在阅读了BufferedReader.readLine()抛出java.net.SocketException:软件导致连接中止:recv失败在几个不同的页面中,我相信这与你的网络有关。由于TCP超时或传输中的数据损坏,连接似乎终止。
I couldn't get your exact problem to replicate on my own computer using your code and localhost-connections, but after reading about "BufferedReader.readLine() throwing java.net.SocketException: Software caused connection abort: recv failed" in several different pages, I believe this is related to your network. The connection seems to be terminated due to TCP timeout or data corrupted in the transmission.
如果这发生在localhost-connections(同一台计算机上的服务器和客户端)上,它可能是一个有故障的内存,否则你可能在某个地方有一个坏的,路由器或电缆沿线。如果您使用无线技术,它们可能非常不可靠。
If this happens over localhost-connections (server and client in same computer), it could be a faulty memory, otherwise you might have a broken nic, router or cable somewhere along the line. If you're using wireless, they can be pretty unreliable.
这篇关于Java错误 - 软件导致连接中止:recv失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!