1

I have developed an Android application that has multiple devices sending data back to a server device via Bluetooth socket connections, however am experiencing the error:

E/bt-btif: send none, EAGAIN or EWOULDBLOCK, errno:11

I have read that these errors occur on socket connections where the receiving device's socket buffer is full, however I am not sure how to handle it in an Android application..Is there a way that I can check for these errors before attempting transmission, or if they occur catch them and retry transmission later?

1 Answers1

2

If you get EAGAIN, simply retry the same operation again.

If you get EWOULDBLOCK, you must be using a non-blocking socket, and the requested operation would have caused the socket to block the calling thread. Use select() to wait for the blocking condition to clear, then retry the original operation again.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • EAGAIN and EWOULDBLOCK are different names for the same `errno.` Only your second paragraph applies. – user207421 Oct 02 '13 at 02:11
  • 1
    EAGAIN is not always the same as EWOULDBLOCK on all platforms, that is why I separated them. [What does EAGAIN mean?](http://stackoverflow.com/questions/4058368/) – Remy Lebeau Oct 02 '13 at 02:12
  • Was interesting to learn about, I got it working by using a BufferedOutputStream for socket communication instead to ensure there was a buffer for bytes that could not be transmitted at that time to be retried later. – keegs_la_trobe Oct 02 '13 at 05:04
  • It's the same. You must call `select()` if you get either `EAGAIN` or `EWOULDBLOCK.` If you recommend an alternative strategy for `EAGAIN` that doesn't involve `select()` you need to provide a citation for that. Another SO answer isn't a normative reference. – user207421 Oct 02 '13 at 06:15