From 9fb286119302c1e21ce76f246d0c6e3ea639fca9 Mon Sep 17 00:00:00 2001 From: Lasse Rosenow Date: Fri, 25 Oct 2024 18:00:58 +0000 Subject: [PATCH] Make accept non blocking --- examples/riot/blinky/Makefile | 2 +- src/platform/posix/tcp_ip_channel.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/riot/blinky/Makefile b/examples/riot/blinky/Makefile index a444960e..61759277 100755 --- a/examples/riot/blinky/Makefile +++ b/examples/riot/blinky/Makefile @@ -13,6 +13,6 @@ DEVELHELP ?= 1 QUIET ?= 1 # Enable reactor-uc features -# CFLAGS += -DNETWORK_POSIX_TCP +CFLAGS += -DNETWORK_POSIX_TCP include $(CURDIR)/../../../make/riot/riot.mk diff --git a/src/platform/posix/tcp_ip_channel.c b/src/platform/posix/tcp_ip_channel.c index 1d9b7c97..6675decc 100644 --- a/src/platform/posix/tcp_ip_channel.c +++ b/src/platform/posix/tcp_ip_channel.c @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -279,6 +280,11 @@ void TcpIpChannel_ctor(TcpIpChannel *self, const char *host, unsigned short port throw("Could not set SO_REUSEADDR"); } + // Set server socket to non-blocking + if (server) { + fcntl(self->fd, F_SETFL, O_NONBLOCK); + } + self->server = server; self->terminate = true; self->protocol_family = protocol_family;