From 2feb8b639e4dfd085e47393e86f7242101262019 Mon Sep 17 00:00:00 2001 From: Valerio De Benedetto Date: Mon, 13 Mar 2023 12:19:47 +0100 Subject: [PATCH] Fix to server-tcp linux example --- examples/linux/platform.h | 4 ++++ examples/linux/server-tcp.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/linux/platform.h b/examples/linux/platform.h index 49b36c8..6b5e71d 100644 --- a/examples/linux/platform.h +++ b/examples/linux/platform.h @@ -106,6 +106,10 @@ int create_tcp_server(const char* address, const char* port) { freeaddrinfo(results); + if (fd < 0) { + return errno; + } + signal(SIGINT, close_server_on_exit); signal(SIGTERM, close_server_on_exit); signal(SIGQUIT, close_server_on_exit); diff --git a/examples/linux/server-tcp.c b/examples/linux/server-tcp.c index 1213f01..c26f2aa 100644 --- a/examples/linux/server-tcp.c +++ b/examples/linux/server-tcp.c @@ -95,7 +95,7 @@ int main(int argc, char* argv[]) { // Set up the TCP server int ret = create_tcp_server(argv[1], argv[2]); if (ret != 0) { - fprintf(stderr, "Error creating TCP server\n"); + fprintf(stderr, "Error creating TCP server - %s\n", strerror(ret)); return 1; }