From: Nick Mathewson Date: Sun, 16 Aug 2009 19:21:57 +0000 (+0000) Subject: Make evhttp_bound_socket visible, and provide an accessor to its fd X-Git-Tag: release-2.0.3-alpha~117 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4bcd5646d8f754a38eec606e2dda37a9696160bb;p=libevent Make evhttp_bound_socket visible, and provide an accessor to its fd Declare the previously private struct evhttp_bound_socket in event2/http.h as an opaque struct. Implement evhttp_bound_socket_get_fd, which returns the file descriptor of an evhttp_bound_socket. [Patch from David Reiss] svn:r1421 --- 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. *