From 1845b7be544f0b16f4cf7f152d438fc9dcd50eee Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Thu, 25 Mar 2021 17:26:55 +0100 Subject: [PATCH] The unix(7) man page recommends using SOCK_SEQPACKET Since Linux 2.6.4 the SOCK_SEQPACKET socket type is available for UNIX domain sockets on Linux. It is intended for; "a sequenced-packet socket that is connection-oriented, preserves message boundaries, and delivers messages in the order that they were sent." which sounds like us. Signed-off-by: Joachim Wiberg --- src/api.c | 2 +- src/client.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api.c b/src/api.c index 2be63205..264276b4 100644 --- a/src/api.c +++ b/src/api.c @@ -444,7 +444,7 @@ int api_init(uev_ctx_t *ctx) }; _d("Setting up external API socket ..."); - sd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0); + sd = socket(AF_UNIX, SOCK_SEQPACKET | SOCK_CLOEXEC, 0); if (-1 == sd) { _pe("Failed starting external API socket"); return 1; diff --git a/src/client.c b/src/client.c index bc6ccc31..d1d529f5 100644 --- a/src/client.c +++ b/src/client.c @@ -38,7 +38,7 @@ int client_connect(void) .sun_path = INIT_SOCKET, }; - sd = socket(AF_UNIX, SOCK_STREAM, 0); + sd = socket(AF_UNIX, SOCK_SEQPACKET, 0); if (-1 == sd) err(1, "Failed creating UNIX domain socket");