Permalink
Browse files

Show how to print a dns error on failure

  • Loading branch information...
1 parent 708491e commit 1d666421778f5e0beda4b8b3e90e9401fd5a9404 Nick Mathewson committed Aug 10, 2010
Showing with 6 additions and 0 deletions.
  1. +6 −0 examples_R6/R6_http_client.c
@@ -4,6 +4,7 @@
#include <event2/dns.h>
#include <event2/bufferevent.h>
#include <event2/buffer.h>
+#include <event2/util.h>
#include <event2/event.h>
#include <stdio.h>
@@ -24,6 +25,11 @@ void eventcb(struct bufferevent *bev, short events, void *ptr)
printf("Connect okay.\n");
} else if (events & (BEV_EVENT_ERROR|BEV_EVENT_EOF)) {
struct event_base *base = ptr;
+ if (events & BEV_EVENT_ERROR) {
+ int err = bufferevent_socket_get_dns_error(bev);
+ if (err)
+ printf("DNS error: %s\n", evutil_gai_strerror(err));
+ }
printf("Closing\n");
bufferevent_free(bev);
event_base_loopexit(base, NULL);

0 comments on commit 1d66642

Please sign in to comment.