Episode 004 – An upgraded Asio resolver

This episode upgrades the resolver from last time by queuing up several async_resolve queries at once. This helps us explore how the Asio implementation handles parallel requests for domain and service resolution. Here’s a hint: it’s not what you’d expect from reading the API.

We also take a look at what happens when one of resolver queries takes a long time and how that affects the others in the queue. Timeouts are usually a good solution to this problem but once again, the Asio implementation has surprises in store.

2 thoughts on “Episode 004 – An upgraded Asio resolver

  1. The reason this is an issue appears to be asio/asio/include/asio/detail/resolver_service.hpp, it uses the OS level getaddrinfo() APIs which are blocking.

    Vert.x fixes this issue in their JVM-based async framework by implementing a simple asynchronous DNS query client. You’ll never get around this issue using the OS APIs.

    Like

  2. Yep Asio seems to fall back to the widely available getaddrinfo() API across platforms and that’s been more than sufficient. Perhaps a reasonable choice given how many (platform specific) ways are available to configure DNS. Now that it’s slotted for the standard library, it will be interesting to see if future versions make the jump to newer OS APIs like getaddrinfo_a() (Linux), GetAddrInfoEx (Windows) and the like.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s