Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我开发了一个 Android 应用程序,它有多个设备通过蓝牙套接字连接将数据发送回服务器设备,但是我遇到了错误:
E/bt-btif: send none, EAGAIN or EWOULDBLOCK, errno:11
我已经读到这些错误发生在接收设备的套接字缓冲区已满的套接字连接上,但是我不确定如何在 Android 应用程序中处理它。有没有办法在尝试传输之前检查这些错误,或者如果它们发生捕获它们并稍后重试传输?
如果得到EAGAIN,只需再次重试相同的操作。
EAGAIN
如果得到EWOULDBLOCK,则必须使用非阻塞套接字,并且请求的操作会导致套接字阻塞调用线程。用于select()等待阻塞条件清除,然后重试原始操作。
EWOULDBLOCK
select()