我有一个正在开发的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/