Skip to content

Commit b898000

Browse files
authored
Feature / Adopt externally accepted sockets into uWebSockets. (#1697)
* Adopt externally accepted sockets into uWebSockets. * Integrate uSockets typo. --------- Co-authored-by: markus <markus.kuehni@triviso.ch>
1 parent 97a72ed commit b898000

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

src/App.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,12 @@ struct TemplatedApp {
575575
return std::move(*this);
576576
}
577577

578+
/* adopt an externally accepted socket */
579+
TemplatedApp &&adoptSocket(LIBUS_SOCKET_DESCRIPTOR accepted_fd) {
580+
httpContext->adoptAcceptedSocket(accepted_fd);
581+
return std::move(*this);
582+
}
583+
578584
TemplatedApp &&run() {
579585
uWS::run();
580586
return std::move(*this);

src/HttpContext.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,11 @@ struct HttpContext {
482482
us_listen_socket_t *listen(const char *path, int options) {
483483
return us_socket_context_listen_unix(SSL, getSocketContext(), path, options, sizeof(HttpResponseData<SSL>));
484484
}
485+
486+
/* Adopt an externally accepted socket into this HttpContext */
487+
us_socket_t *adoptAcceptedSocket(LIBUS_SOCKET_DESCRIPTOR accepted_fd) {
488+
return us_adopt_accepted_socket(SSL, getSocketContext(), accepted_fd, sizeof(HttpResponseData<SSL>), 0, 0);
489+
}
485490
};
486491

487492
}

0 commit comments

Comments
 (0)