蓝牙插座连接
我如何知道BluetoothSocket是否仍然连接到端点?如何检测套接字是否已被端点断开连接?
谢谢
How can i know if a BluetoothSocket is still connected to the endpoint? How can i detect if the socket has been disconnected by the endpoint?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在我的应用程序中,我跟踪 I/O 错误。如果
read()
成功,那么我会重置计数器。如果错误计数器上升到足够高(4-5 通常是一个不错的数字),那么我认为连接已失效,并继续将其拆除并重新构建它。SDK谈论了状态改变意图,但我不清楚它是指特定连接,还是蓝牙适配器本身此处:
In my apps, I keep track of I/O errors. If a successful
read()
takes place, then I reset the counters. If the error counters go up high enough (4-5 is usually a good number) then I consider the connection dead, and proceed to tear it down and re-build it.The SDK talks about a state change intent, but I'm not clear whether it's referring to a specific connection, or the bluetooth adapter itself here: