ostream os( &request_buffer );
os << icmp_packet;
- // Send the request.
TimeSent = microsec_clock::universal_time();
+
+ // Send the request.
+ string dest_address_string = DestinationEndpoint.address().to_string();
+ BOOST_ASSERT( !dest_address_string.empty() );
Socket.send_to( request_buffer.data(), DestinationEndpoint );
schedule_timeout_echo_reply();
// Wait up to N seconds for a reply.
RepliesCount = 0;
Timer.expires_at( TimeSent + seconds( EchoReplyTimeoutInSec ) );
- Timer.async_wait( boost::bind( &BoostPinger::handle_timeout, this ) );
+ Timer.async_wait(
+ boost::bind( &BoostPinger::handle_timeout_echo_reply, this )
+ );
}
-void BoostPinger::handle_timeout()
+void BoostPinger::handle_timeout_echo_reply()
{
if ( RepliesCount == 0 )
cout << "Request timed out" << endl;
// Wait for a reply. We prepare the buffer to receive up to 64KB.
Socket.async_receive(
ReplyBuffer.prepare( 65536 ),
- boost::bind( &BoostPinger::handle_receive, this, _2 )
+ boost::bind( &BoostPinger::handle_receive_echo_reply, this, _2 )
);
}
-void BoostPinger::handle_receive( const size_t &bytes_transferred )
+void BoostPinger::handle_receive_echo_reply( const size_t &bytes_transferred )
{
// The actual number of bytes received is committed to the buffer so that we
// can extract it using a std::istream object.
// expected sequence number.
if ( is && icmp_packet.match( IcmpHeader::EchoReply, get_identifier(), SequenceNumber ) )
{
- // If this is the first reply, interrupt the five second timeout.
+ // If this is the first reply, interrupt the echo reply timeout.
if ( RepliesCount == 0 )
Timer.cancel();
IcmpPacket create_echo_request();
void send_echo_request( const IcmpPacket &icmp_packet );
void schedule_timeout_echo_reply();
- void handle_timeout();
+ void handle_timeout_echo_reply();
void schedule_next_echo_request();
void start_receive();
- void handle_receive( const std::size_t &bytes_transferred );
+ void handle_receive_echo_reply( const std::size_t &bytes_transferred );
void print_echo_reply(
const IcmpPacket &icmp_packet,
const std::size_t &bytes_transferred