我有一个正在开发的 android 应用程序,在某个阶段我得到了
"[CDS]shutdownInput in read "
连续出现在我的日志查看器中?
这意味着什么?我做错了什么导致出现这条消息?
我有一个线程正在检查输入流。
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");
}
}
最佳答案
每当 TCP 连接试图从缓冲区读取而另一端已断开连接时,就会显示此错误消息。如果您正在发送数据,通常在超时后。checkError() 将返回 true
关于java - 在 logCat 中获取 "[CDS] shutdownInput in read",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24552226/