我有一个我正在开发的android应用程序,在某个阶段,我得到了
是否在我的日志查看器中持续显示" [CDS]shutdownInput in read "?
这需要什么?我做错了什么才导致这条消息出现?
我有一个检查in流的线程。
Thread thread = new Thread(new Runnable() {
public void run() {
while (true) {
mySocket.ReadFromSocket();
try {
Thread.sleep(500);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public byte[] ReadFromSocket() throws IOException {
if (socketState == SocketState.CONNECTED) {
byte[] buffer = new byte[1024];
int noOfBytesRead = nis.read(buffer, 0, 1024); // This is blocking
while (noOfBytesRead == -1) {
noOfBytesRead = nis.read(buffer, 0, 1024); // This is blocking
try {
Thread.sleep(50);
} catch (InterruptedException e) {
}
}
byte[] tempdata = new byte[noOfBytesRead];
System.arraycopy(buffer, 0, tempdata, 0, noOfBytesRead);
return tempdata;
} else {
throw new IOException("Socket Not Connected");
}
}发布于 2016-08-31 03:59:40
只要TCP连接尝试从缓冲区读取,而另一端已丢弃该连接,就会显示此错误消息。通常在超时后,如果您正在发送数据,out.checkError()将返回true
https://stackoverflow.com/questions/24552226
复制相似问题