开发者

Bluetooth on Android 2.2 : socket doesn't receive "connection canceled"

开发者 https://www.devze.com 2023-04-07 06:08 出处:网络
I\'m in process of writing Android 2.2 application with BT support. Two BT devices need to exchange messages.

I'm in process of writing Android 2.2 application with BT support. Two BT devices need to exchange messages.

The problem I encountered ha开发者_如何学JAVAppens when one of devices (server) crashes/switches off or somehow stops connection. It's socket is disappeared and another participant (client) simply doesn't know it should attempt reconnect.

When the first (crashed) participant raises again, the client has no idea it should reconnect and continues to send messages. The server is filled with errors of BT stack like: E/BTL-IFS_WRAPPER (11222): wrp_find_wsock: wrp_find_wsock invalid hdl -1.

I understand the server's BT discovers someone send messages to already closed socket.

So the basic question is how to put client in reconnect mode when the server is crashed? I see only one possibility to utilize two way "keep alive" packets every few seconds and drop the server to the listener mode and the client to the connecting mode.

0

精彩评论

暂无评论...
验证码 换一张
取 消