BoostPinger p( io_service );
Configuration config = config_reader.get_configuration();
Host host = config.get_host();
- p.ping( host );
+ string destination = host.get_address();
+ p.ping( destination );
}
catch ( std::exception& e )
{
//-----------------------------------------------------------------------------
BoostPinger::BoostPinger(
- boost::asio::io_service& io_service
+ boost::asio::io_service &io_service
) :
io_service( io_service ),
Resolver( io_service ),
{
}
-void BoostPinger::ping( const Host &host )
+void BoostPinger::ping( const std::string &destination )
{
- BOOST_ASSERT( !host.get_address().empty() );
- BOOST_ASSERT( ( 0 < host.get_interval() ) && ( host.get_interval() < UINT_MAX ) );
+ BOOST_ASSERT( !destination.empty() );
- std::string destination = host.get_address();
icmp::resolver::query query( icmp::v4(), destination, "" );
DestinationEndpoint = *Resolver.resolve( query );
}
}
-void BoostPinger::send( const boost::asio::streambuf& request_buffer )
+void BoostPinger::send( const boost::asio::streambuf &request_buffer )
{
// Send the request.
TimeSent = posix_time::microsec_clock::universal_time();
);
}
-void BoostPinger::handle_receive( const std::size_t length )
+void BoostPinger::handle_receive( const std::size_t &length )
{
// The actual number of bytes received is committed to the buffer so that we
// can extract it using a std::istream object.
class BoostPinger : public Pinger
{
public:
- BoostPinger( boost::asio::io_service& io_service );
+ BoostPinger( boost::asio::io_service &io_service );
virtual ~BoostPinger();
- void ping( const Host &host );
+ void ping( const std::string &destination );
private:
void start_send();
- void send( const boost::asio::streambuf& request_buffer );
+ void send( const boost::asio::streambuf &request_buffer );
void handle_timeout();
void start_receive();
- void handle_receive( const std::size_t length );
+ void handle_receive( const std::size_t &length );
static uint16_t get_identifier();
private:
- boost::asio::io_service& io_service;
+ boost::asio::io_service &io_service;
icmp::resolver Resolver;
icmp::endpoint DestinationEndpoint;
icmp::socket Socket;
#include <string>
-#include "host.h"
-
//-----------------------------------------------------------------------------
// Pinger
//-----------------------------------------------------------------------------
Pinger();
virtual ~Pinger();
- virtual void ping( const Host &host ) = 0;
+ virtual void ping( const std::string &destination ) = 0;
};