Trouble in paradise, and how to support timeout?

4 views
Skip to first unread message

Thomas

unread,
Jan 20, 2008, 2:47:03 PM1/20/08
to bluecove-users
I am currently trying to support connection timeouts in my bluetooth
service. Because sometimes the client or the server stop listening or
sending data to the other side. Now I am curious what's the best way
to implement the support of connection timeouts? I have the following
ideas:

1. Raise InterruptException when it was unable to send the data
for more then three times.
2. Check in the listen-loop wha the last activity time was and if
it's longer then 5-10 seconds drop the connection

Are there any good examples of this, or good practice?

Earlier today I also received some strange exception while testing my
bluetooth service:

[java] 22:24:55 [DBG ]: java.io.IOException: Failed to write
[0xe00002d7]
[java] java.io.IOException: Failed to write [0xe00002d7]
[java] at
com.intel.bluetooth.BluetoothStackOSX.connectionRfWrite(Native Method)
[java] at
com.intel.bluetooth.BluetoothRFCommOutputStream.write(BluetoothRFCommOutputStream.java:
81)
[java] at java.io.OutputStream.write(OutputStream.java:58)

Thanks!

Thomas

Vlad Skarzhevskyy

unread,
Jan 20, 2008, 4:10:47 PM1/20/08
to bluecov...@googlegroups.com
First I believe that any error/exception is a connection drop and
can't be recovered from.
But this may not be the absolute true, you need to experiment with each stack.

I can't directly answer to you "the best way" question. But here some
information that may help.

For RFCOMM InputStream.read() will return -1 if connection has been
closed gracefully on another end.

As to BlueCove "boolean timeouts" param in Connector.open has effect
only for obex connections. There not much in specification and in
native stacks APIs that will suggest how this can should be properly
implemented.

For OS X. Error codes can be found on this page:
http://developer.apple.com/documentation/Darwin/Reference/IOKit/IOReturn/CompositePage.html

Your case: The device is offline (0xe00002d7).

Reply all
Reply to author
Forward
0 new messages