const int echo_reply_timeout_in_sec
) :
IoService( io_serv ),
- Resolver( io_serv ),
DestinationEndpoint(),
Socket( io_serv, icmp::v4() ),
Timer( io_serv ),
}
/**
- * Pings a given destination address.
+ * Ping a destination address from an available local source.
*
- * @param destination The address of the host where to ping.
+ * @param destination_ip The address of the host to ping.
*
* @return true if the ping was successfully performed, or false if the ping
- * was not replied due timeout.
+ * was not replied due a timeout.
*
* @note This method is synchronous, i.e. this method blocks and returns only
* after the ping requested has finished or timed-out.
*/
-bool BoostPinger::ping( const string &destination )
+bool BoostPinger::ping( const string &destination_ip )
{
- BOOST_ASSERT( !destination.empty() );
+ BOOST_ASSERT( !destination_ip.empty() );
- icmp::resolver::query query( icmp::v4(), destination, "" );
- DestinationEndpoint = *Resolver.resolve( query );
+ int port = 0;
+ address destination_address = ip::address::from_string( destination_ip );
+ icmp::endpoint destination_endpoint( destination_address, port );
+ DestinationEndpoint = destination_endpoint;
start_pinger();
);
virtual ~BoostPinger();
- bool ping( const std::string &destination );
+ bool ping( const std::string &destination_ip );
private:
enum PingStatus
private:
boost::asio::io_service &IoService;
- boost::asio::ip::icmp::resolver Resolver;
boost::asio::ip::icmp::endpoint DestinationEndpoint;
boost::asio::ip::icmp::socket Socket;
boost::asio::deadline_timer Timer;