| Home | Libraries | People | FAQ | More

# boost::asio::basic_resolver< Protocol, Service > Class Template Reference

Inherits boost::asio::basic_io_object< Service >< Service >.

Inheritance diagram for boost::asio::basic_resolver< Protocol, Service >:

List of all members.

## Detailed Description

### template<typename Protocol, typename Service = resolver_service<Protocol>>
class boost::asio::basic_resolver< Protocol, Service >

Provides endpoint resolution functionality.

The basic_resolver class template provides the ability to resolve a query to a list of endpoints.

Thread Safety:
  Distinct objects: Safe.
  Shared objects: Unsafe.

Concepts:
  Async_Object, Error_Source.

## Public Types

typedef Protocol | protocol_type
| The protocol type.
typedef Protocol::endpoint | endpoint_type
| The endpoint type.
typedef Protocol::resolver_query | query
| The query type.
typedef Protocol::resolver_iterator | iterator
| The iterator type.
typedef boost::asio::error | error_type
| The type used for reporting errors.
typedef Service | service_type
| The type of the service that will be used to provide I/O operations.
typedef service_type::implementation_type | implementation_type
| The underlying implementation type of I/O object.

## Public Member Functions

| basic_resolver (boost::asio::io_service &io_service)
| Constructor.
void | cancel ()
| Cancel any asynchronous operations that are waiting on the resolver.
iterator | resolve (const query &q)
| Resolve a query to a list of entries.
template<typename Error_Handler>
iterator | resolve (const query &q, Error_Handler error_handler)
| Resolve a query to a list of entries.
template<typename Handler>
void | async_resolve (const query &q, Handler handler)
| Asynchronously resolve a query to a list of entries.
iterator | resolve (const endpoint_type &e)
| Resolve an endpoint to a list of entries.
template<typename Error_Handler>
iterator | resolve (const endpoint_type &e, Error_Handler error_handler)
| Resolve an endpoint to a list of entries.
template<typename Handler>
void | async_resolve (const endpoint_type &e, Handler handler)
| Asynchronously resolve an endpoint to a list of entries.
boost::asio::io_service & | io_service ()
| Get the io_service associated with the object.

## Member Typedef Documentation

template<typename Protocol, typename Service = resolver_service<Protocol>>

typedef Protocol boost::asio::basic_resolver< Protocol, Service >::protocol_type

The protocol type.

template<typename Protocol, typename Service = resolver_service<Protocol>>

typedef Protocol::endpoint boost::asio::basic_resolver< Protocol, Service >::endpoint_type

The endpoint type.

template<typename Protocol, typename Service = resolver_service<Protocol>>

typedef Protocol::resolver_query boost::asio::basic_resolver< Protocol, Service >::query

The query type.

template<typename Protocol, typename Service = resolver_service<Protocol>>

typedef Protocol::resolver_iterator boost::asio::basic_resolver< Protocol, Service >::iterator

The iterator type.

template<typename Protocol, typename Service = resolver_service<Protocol>>

typedef boost::asio::error boost::asio::basic_resolver< Protocol, Service >::error_type

The type used for reporting errors.

template<typename Service>

typedef Service boost::asio::basic_io_object< Service >::service_type `[inherited]`

The type of the service that will be used to provide I/O operations.

template<typename Service>

typedef service_type::implementation_type boost::asio::basic_io_object< Service >::implementation_type `[inherited]`

The underlying implementation type of I/O object.

## Constructor & Destructor Documentation

template<typename Protocol, typename Service = resolver_service<Protocol>>

boost::asio::basic_resolver< Protocol, Service >::basic_resolver | ( | boost::asio::io_service & | io_service | ) | `[explicit]`

Constructor.

This constructor creates a basic_resolver.

Parameters:

  | io_service | The io_service object that the resolver will use to dispatch handlers for any asynchronous operations performed on the timer.

## Member Function Documentation

template<typename Protocol, typename Service = resolver_service<Protocol>>

void boost::asio::basic_resolver< Protocol, Service >::cancel | ( |  | ) |

Cancel any asynchronous operations that are waiting on the resolver.

This function forces the completion of any pending asynchronous operations on the host resolver. The handler for each cancelled operation will be invoked with the boost::asio::error::operation_aborted error code.

template<typename Protocol, typename Service = resolver_service<Protocol>>

iterator boost::asio::basic_resolver< Protocol, Service >::resolve | ( | const query & | q | ) |

Resolve a query to a list of entries.

This function is used to resolve a query into a list of endpoint entries.

Parameters:

  | q | A query object that determines what endpoints will be returned.

Returns:
  A forward-only iterator that can be used to traverse the list of endpoint entries.

Exceptions:

  | boost::asio::error | Thrown on failure.

Note:
  A default constructed iterator represents the end of the list.

  A successful call to this function is guaranteed to return at least one entry.

template<typename Protocol, typename Service = resolver_service<Protocol>>
template<typename Error_Handler>

iterator boost::asio::basic_resolver< Protocol, Service >::resolve | ( | const query & | q,
|  | Error_Handler | error_handler |
| ) |  |  |

Resolve a query to a list of entries.

This function is used to resolve a query into a list of endpoint entries.

Parameters:

  | q | A query object that determines what endpoints will be returned.

Returns:
  A forward-only iterator that can be used to traverse the list of endpoint entries. Returns a default constructed iterator if an error occurs.

Parameters:

  error_handler

  A handler to be called when the operation completes, to indicate whether or not an error has occurred. Copies will be made of the handler as required. The function signature of the handler must be:

       void error_handler(
         const boost::asio::error& error // Result of operation.
       );

Note:
  A default constructed iterator represents the end of the list.

  A successful call to this function is guaranteed to return at least one entry.

template<typename Protocol, typename Service = resolver_service<Protocol>>
template<typename Handler>

void boost::asio::basic_resolver< Protocol, Service >::async_resolve | ( | const query & | q,
|  | Handler | handler |
| ) |  |  |

Asynchronously resolve a query to a list of entries.

This function is used to asynchronously resolve a query into a list of endpoint entries.

Parameters:

  | q | A query object that determines what endpoints will be returned.

  handler

  The handler to be called when the resolve operation completes. Copies will be made of the handler as required. The function signature of the handler must be:

       void handler(
         const boost::asio::error& error,   // Result of operation.
         resolver::iterator iterator // Forward-only iterator that can be used to
                                     // traverse the list of endpoint entries.
       );

  Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a manner equivalent to using boost::asio::io_service::post().

Note:
  A default constructed iterator represents the end of the list.

  A successful resolve operation is guaranteed to pass at least one entry to the handler.

template<typename Protocol, typename Service = resolver_service<Protocol>>

iterator boost::asio::basic_resolver< Protocol, Service >::resolve | ( | const endpoint_type & | e | ) |

Resolve an endpoint to a list of entries.

This function is used to resolve an endpoint into a list of endpoint entries.

Parameters:

  | e | An endpoint object that determines what endpoints will be returned.

Returns:
  A forward-only iterator that can be used to traverse the list of endpoint entries.

Exceptions:

  | boost::asio::error | Thrown on failure.

Note:
  A default constructed iterator represents the end of the list.

  A successful call to this function is guaranteed to return at least one entry.

template<typename Protocol, typename Service = resolver_service<Protocol>>
template<typename Error_Handler>

iterator boost::asio::basic_resolver< Protocol, Service >::resolve | ( | const endpoint_type & | e,
|  | Error_Handler | error_handler |
| ) |  |  |

Resolve an endpoint to a list of entries.

This function is used to resolve an endpoint into a list of endpoint entries.

Parameters:

  | e | An endpoint object that determines what endpoints will be returned.

Returns:
  A forward-only iterator that can be used to traverse the list of endpoint entries. Returns a default constructed iterator if an error occurs.

Parameters:

  error_handler

  A handler to be called when the operation completes, to indicate whether or not an error has occurred. Copies will be made of the handler as required. The function signature of the handler must be:

       void error_handler(
         const boost::asio::error& error // Result of operation.
       );

Note:
  A default constructed iterator represents the end of the list.

  A successful call to this function is guaranteed to return at least one entry.

template<typename Protocol, typename Service = resolver_service<Protocol>>
template<typename Handler>

void boost::asio::basic_resolver< Protocol, Service >::async_resolve | ( | const endpoint_type & | e,
|  | Handler | handler |
| ) |  |  |

Asynchronously resolve an endpoint to a list of entries.

This function is used to asynchronously resolve an endpoint into a list of endpoint entries.

Parameters:

  | e | An endpoint object that determines what endpoints will be returned.

  handler

  The handler to be called when the resolve operation completes. Copies will be made of the handler as required. The function signature of the handler must be:

       void handler(
         const boost::asio::error& error,   // Result of operation.
         resolver::iterator iterator // Forward-only iterator that can be used to
                                     // traverse the list of endpoint entries.
       );

  Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a manner equivalent to using boost::asio::io_service::post().

Note:
  A default constructed iterator represents the end of the list.

  A successful resolve operation is guaranteed to pass at least one entry to the handler.

template<typename Service>

boost::asio::io_service& boost::asio::basic_io_object< Service >::io_service | ( |  | ) | `[inherited]`

Get the io_service associated with the object.

This function may be used to obtain the io_service object that the I/O object uses to dispatch handlers for asynchronous operations.

Returns:
  A reference to the io_service object that the I/O object will use to dispatch handlers. Ownership is not transferred to the caller.

| Copyright © 2003 - 2006 Christopher M. Kohlhoff