[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] evhttp client and IPv6



On Thu, Feb 14, 2013 at 7:28 PM, Patrick Pelletier
<ppelletier@xxxxxxxxxx> wrote:
 [...]
>
> I've been similarly frustrated with the lack of evhttp client examples,
> especially ones that properly show how to do error handling, IPv6, and
> https.  I've created a repo (because it's just a little too big to feel
> comfortable as a gist) with my code in it:
>
> https://github.com/ppelleti/https-example

For the record: I would *LOVE* to incorporate some good HTTPS and
client examples.

(I'd also like to remind people to consider trying Mark Ellzey's
"libevhtp" too, since I think it's a more solid backend than
Libevent's built-in evhttp.)

> I'd like to (with some help) get this example into shape where it shows the
> "best practices" for doing all these things, and then potentially contribute
> it back to libevent, to go in the "sample" directory, because currently the
> "sample" directory of the libevent repo only has an http server example, but
> not an http client example.  I've been told that the reason there are so few
> examples is because the tests also serve as examples, but personally I
> haven't found the tests all that satisfying as examples, either.

Wow: I sure hope I didn't tell you that.  If I did, I apologize.  The
evhttp unit tests are not terribly readable or well-commented IMO.

>  So, that's
> why I'd still like to contribute a client/server example (including https,
> IPv6, and error handling) for evhttp to the libevent "samples" directory.
>
> Although Azat's patch is a good first step for IPv6 support in evhttp, I
> think some more work is still necessary.  In particular,
> bufferevent_connect_getaddrinfo_cb() in bufferevent_sock.c has the comment
> "XXX use the other addrinfos?".  I think we need to do this, in case a host
> has both an IPv4 address and an IPv6 address, but the server is only running
> on IPv4 or IPv6, but not both.

Agreed.  It will probably need some connect/retry logic and flags.

> Currently, libevent will only try the first
> address and give up, but I think it needs to try the other one (e. g. IPv4)
> if the first one (e. g. IPv6) fails.  This is the problem I was running
> into, since "localhost" resolves to both "::1" and "127.0.0.1", and my
> server was only running on "127.0.0.1".  libevent tried "::1" first, saw no
> server was running there, and gave up, rather than moving on to "127.0.0.1"
> which would have succeeded.
>
> The other thing people will tell you is to use libevhtp instead of evhttp.
> If you don't need Windows support, you might want to look into that.  It's
> not an option for me, though, since I need a cross-platform solution, and
> libevhtp doesn't (yet) support Windows.

When I last looked at porting libevhtp to Windows, it didn't seem as
though it would be terribly hard, assuming a decent working knowledge
of how to write unix/windows portable network code with Libevent.  If
somebody wants to do this, I bet Mark would take tasteful patches.

yrs,
-- 
Nick
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.