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.
精彩评论