diff --git a/http.c b/http.c index 52362bc9..39528fc7 100644 --- a/http.c +++ b/http.c @@ -2433,6 +2433,11 @@ evhttp_accept_socket(struct evhttp *http, evutil_socket_t fd) return (0); } +evutil_socket_t evhttp_bound_socket_get_fd(struct evhttp_bound_socket *bound) +{ + return bound->bind_ev.ev_fd; +} + static struct evhttp* evhttp_new_object(void) { diff --git a/include/event2/http.h b/include/event2/http.h index e1ddaee7..93c805f8 100644 --- a/include/event2/http.h +++ b/include/event2/http.h @@ -69,6 +69,7 @@ struct event_base; struct evhttp; struct evhttp_request; struct evkeyvalq; +struct evhttp_bound_socket; /** * Create a new HTTP server. @@ -111,6 +112,15 @@ int evhttp_bind_socket(struct evhttp *http, const char *address, ev_uint16_t por */ int evhttp_accept_socket(struct evhttp *http, evutil_socket_t fd); +/** + * Get the raw file descriptor referenced by an evhttp_bound_socket. + * + * @param bound_socket a handle returned by evhttp_{bind,accept}_socket_with_handle + * @return the file descriptor used by the bound socket + * @see evhttp_bind_socket_with_handle(), evhttp_accept_socket_with_handle() + */ +evutil_socket_t evhttp_bound_socket_get_fd(struct evhttp_bound_socket *bound_socket); + /** * Free the previously created HTTP server. *