From: Andrei Emeltchenko <andrei.emeltchenko@xxxxxxxxx> Set socket buffer sizes for socketpair's end and real RFCOMM socket equal to SOCKET_BUFFER. --- android/socket.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/android/socket.c b/android/socket.c index 6293b59..3898767 100644 --- a/android/socket.c +++ b/android/socket.c @@ -82,6 +82,9 @@ static struct rfcomm_sock *create_rfsock(int sock, int *hal_fd) { int fds[2] = {-1, -1}; struct rfcomm_sock *rfsock; + socklen_t len = sizeof(int); + int size = SOCKET_BUFFER; + int i; if (socketpair(AF_LOCAL, SOCK_STREAM, 0, fds) < 0) { error("socketpair(): %s", strerror(errno)); @@ -94,6 +97,15 @@ static struct rfcomm_sock *create_rfsock(int sock, int *hal_fd) *hal_fd = fds[1]; rfsock->real_sock = sock; + for (i = 0; i < 2; i++) { + if (setsockopt(fds[i], SOL_SOCKET, SO_SNDBUF, &size, len) < 0) + warn("setsockopt() SO_SNDBUF fd: %d %s", fds[i], + strerror(errno)); + if (setsockopt(fds[i], SOL_SOCKET, SO_RCVBUF, &size, len) < 0) + warn("setsockopt() SO_RCVBUF fd: %d %s", fds[i], + strerror(errno)); + } + rfsock->buf = g_malloc(SOCKET_BUFFER); return rfsock; -- 1.8.3.2 -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html