libevhtp icon indicating copy to clipboard operation
libevhtp copied to clipboard

Migrating from ev_http: How to get the socket for evhtp_accept_socket()?

Open RokerHRO opened this issue 4 years ago • 1 comments

I'm porting my program from ev_http to libevhtp.

So I'm calling evhtp_accept_socket() but this function wants a evutil_socket_t. Where do I get this from? In ev_http the "bind_socket" function returns a socket that I can put into accept_socket.

Unfortunately the examples are lacking any documentation, also the evhtp.h has fancy Doxygen comments, but without enough information in it (e.g. is 0 or -1 the error return value? What does the "backlog" parameter mean? etc.), so I don't see where the socket is bound (and to which address and port?), where the accept is done and how etc.

It would be nice if the examples would contain more comments and Doxygen comments in evhtp.h are filled and not only dummies.

Even better when there would exist a migration guideline document, I think I am not the first person who wants to migrate from ev_http to libevhtp.

RokerHRO avatar May 13 '20 15:05 RokerHRO

Okay, it seems that evhtp_bind_socket() does a lot more than just binding the socket. It also does the "listen()" and "accept()" of the classic BSD socket API. Am I right? It should be documented more clearly so people that are familiar with the classic BSD socket API are not confused about the magic.

RokerHRO avatar May 13 '20 16:05 RokerHRO