From b898000e89ecdcffd0d316d9750236bc09732f21 Mon Sep 17 00:00:00 2001 From: markmaker Date: Mon, 22 Jan 2024 07:31:28 +0100 Subject: [PATCH] Feature / Adopt externally accepted sockets into uWebSockets. (#1697) * Adopt externally accepted sockets into uWebSockets. * Integrate uSockets typo. --------- Co-authored-by: markus --- src/App.h | 6 ++++++ src/HttpContext.h | 5 +++++ uSockets | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/App.h b/src/App.h index 10ca423..904e218 100644 --- a/src/App.h +++ b/src/App.h @@ -575,6 +575,12 @@ public: return std::move(*this); } + /* adopt an externally accepted socket */ + TemplatedApp &&adoptSocket(LIBUS_SOCKET_DESCRIPTOR accepted_fd) { + httpContext->adoptAcceptedSocket(accepted_fd); + return std::move(*this); + } + TemplatedApp &&run() { uWS::run(); return std::move(*this); diff --git a/src/HttpContext.h b/src/HttpContext.h index f66b6ea..11d1a4e 100644 --- a/src/HttpContext.h +++ b/src/HttpContext.h @@ -482,6 +482,11 @@ public: us_listen_socket_t *listen(const char *path, int options) { return us_socket_context_listen_unix(SSL, getSocketContext(), path, options, sizeof(HttpResponseData)); } + + /* Adopt an externally accepted socket into this HttpContext */ + us_socket_t *adoptAcceptedSocket(LIBUS_SOCKET_DESCRIPTOR accepted_fd) { + return us_adopt_accepted_socket(SSL, getSocketContext(), accepted_fd, sizeof(HttpResponseData), 0, 0); + } }; } diff --git a/uSockets b/uSockets index a15d9bb..07654e4 160000 --- a/uSockets +++ b/uSockets @@ -1 +1 @@ -Subproject commit a15d9bbdea68fd02dab40d2394200deb1b883aa6 +Subproject commit 07654e4fb998e5c8ca6c94856bb660c8a53c1846