java - 在 logCat 中获取 "[CDS] shutdownInput in read"

标签 java android sockets android-networking

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

相关文章:

java - 使用带参数的 HQL 选择表行

java - 构建XML服务解析库

java - Android - 创建后台服务以接收 PubNub 消息

java - 在 Android 应用程序中检查互联网连接

android - 当所有 EditText 完成时启用按钮

Python IRC Bot 静默超时(?) - 突然停止工作

c - 套接字服务器写回客户端

java - 保留服务器 : how to terminate a blocking instance (eval taking forever)?

voice-recognition - Android HTC Desire 语音输入问题

Linux:关闭后的 recv() 返回 "bad file descriptor"