From af075b6ab091b06ea9e1bbc1757c958d7ac73e56 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 28 Nov 2011 13:10:58 +1100 Subject: [PATCH] desktop: setup TCP sockets as non-blocking the sendto() blocks unexpectedly on MacOS --- libraries/Desktop/support/FastSerial.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libraries/Desktop/support/FastSerial.cpp b/libraries/Desktop/support/FastSerial.cpp index 70b60d9fc0..34f9269bb4 100644 --- a/libraries/Desktop/support/FastSerial.cpp +++ b/libraries/Desktop/support/FastSerial.cpp @@ -45,6 +45,7 @@ #include #include #include "desktop.h" +#include "util.h" #define LISTEN_BASE_PORT 5760 #define BUFFER_SIZE 128 @@ -129,6 +130,9 @@ static void tcp_start_connection(unsigned int serial_port, bool wait_for_connect } setsockopt(s->fd, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one)); s->connected = true; + if (!desktop_state.slider) { + set_nonblocking(s->fd); + } } } @@ -171,6 +175,9 @@ static void check_connection(struct tcp_state *s) s->connected = true; setsockopt(s->fd, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one)); printf("New connection on serial port %u\n", s->serial_port); + if (!desktop_state.slider) { + set_nonblocking(s->fd); + } } } }