From 77d29ed78b3fd0efc9e0469b4268bcda6254cc71 Mon Sep 17 00:00:00 2001 From: Adrian Liechti Date: Mon, 1 Apr 2024 00:06:26 +0200 Subject: [PATCH 1/2] Unix Socket PoC --- examples/server/server.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/server/server.cpp b/examples/server/server.cpp index 92090b92028aa..73502dfa2ab69 100644 --- a/examples/server/server.cpp +++ b/examples/server/server.cpp @@ -2861,6 +2861,11 @@ int main(int argc, char ** argv) { svr->set_read_timeout (sparams.read_timeout); svr->set_write_timeout(sparams.write_timeout); + if (sparams.hostname.substr(0, 7) == "unix://") { + svr->set_address_family(AF_UNIX); + sparams.hostname = sparams.hostname.substr(7); + } + if (!svr->bind_to_port(sparams.hostname, sparams.port)) { fprintf(stderr, "\ncouldn't bind to server socket: hostname=%s port=%d\n\n", sparams.hostname.c_str(), sparams.port); return 1; From 0b70ac0f6606fd1583afeed5a0bacec035d34444 Mon Sep 17 00:00:00 2001 From: Adrian Liechti Date: Mon, 1 Apr 2024 10:25:47 +0200 Subject: [PATCH 2/2] ingore unix sockets on windows --- examples/server/server.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/server/server.cpp b/examples/server/server.cpp index 73502dfa2ab69..f8960931bfc09 100644 --- a/examples/server/server.cpp +++ b/examples/server/server.cpp @@ -2861,10 +2861,12 @@ int main(int argc, char ** argv) { svr->set_read_timeout (sparams.read_timeout); svr->set_write_timeout(sparams.write_timeout); +#ifndef _WIN32 if (sparams.hostname.substr(0, 7) == "unix://") { svr->set_address_family(AF_UNIX); sparams.hostname = sparams.hostname.substr(7); } +#endif if (!svr->bind_to_port(sparams.hostname, sparams.port)) { fprintf(stderr, "\ncouldn't bind to server socket: hostname=%s port=%d\n\n", sparams.hostname.c_str(), sparams.port);