Skip to content

receiveThread 在对方连接断开或中断的情况下,继续接收问题 #69

@zjlg99

Description

@zjlg99

使用按长度自动接收数据的方式时,当client 端异常时,receivethread 还一直循环接收,反复调用onResponse() 显示接收为null,造成APP 卡顿。解觉办法:
在SocketInputReader中的readToLength()函数捕获异常并抛出异常,这时receivethread 会结束socket链接并退出。
do { readCount = this.inputStream.read(buffer, index, length - index); index += readCount; } while (readCount != -1 && index < length);
该段代码read函数抛出异常后,异常处理返回null,修改为抛出异常即可。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions