diff --git a/src/local.c b/src/local.c index b7da9b31..60a87e47 100644 --- a/src/local.c +++ b/src/local.c @@ -211,6 +211,12 @@ static void server_recv_cb (EV_P_ ev_io *w, int revents) else { ERROR("sendto"); + if (errno == ENOTCONN) + { + LOGE("fast open is not supported on this platform"); + // just turn it off + fast_open = 0; + } close_and_free_remote(EV_A_ remote); close_and_free_server(EV_A_ server); return; diff --git a/src/server.c b/src/server.c index 0ef3e92f..8dbe103a 100644 --- a/src/server.c +++ b/src/server.c @@ -100,7 +100,18 @@ int create_and_bind(const char *host, const char *port) if (fast_open) { opt = 5; - setsockopt(listen_sock, SOL_TCP, TCP_FASTOPEN, &opt, sizeof(opt)); + int r = setsockopt(listen_sock, IPPROTO_TCP, TCP_FASTOPEN, &opt, sizeof(opt)); + if (r == -1) + { + if (errno == EPROTONOSUPPORT || errno == ENOPROTOOPT) + { + LOGE("fast open is not supported on this platform"); + } + else + { + ERROR("setsockopt"); + } + } } #endif