Skip to content

Commit

Permalink
Feature / Adopt externally accepted sockets into uWebSockets. (#1697)
Browse files Browse the repository at this point in the history
* Adopt externally accepted sockets into uWebSockets.

* Integrate uSockets typo.

---------

Co-authored-by: markus <[email protected]>
  • Loading branch information
markmaker and markmaker authored Jan 22, 2024
1 parent 97a72ed commit b898000
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/App.h
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,12 @@ struct TemplatedApp {
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);
Expand Down
5 changes: 5 additions & 0 deletions src/HttpContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,11 @@ struct HttpContext {
us_listen_socket_t *listen(const char *path, int options) {
return us_socket_context_listen_unix(SSL, getSocketContext(), path, options, sizeof(HttpResponseData<SSL>));
}

/* 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<SSL>), 0, 0);
}
};

}
Expand Down
2 changes: 1 addition & 1 deletion uSockets

0 comments on commit b898000

Please sign in to comment.