Placed start_receive() method closer to the schedule_timeout_echo_reply(), where...
authorGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Tue, 2 Aug 2011 10:40:33 +0000 (07:40 -0300)
committerGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Tue, 2 Aug 2011 10:40:33 +0000 (07:40 -0300)
src/icmp/icmppinger.cpp
src/icmp/icmppinger.h

index 6440660..e7c31dd 100644 (file)
@@ -186,18 +186,6 @@ void IcmpPinger::schedule_timeout_echo_reply()
     );
 }
 
-void IcmpPinger::start_receive()
-{
-    // Discard any data already in the buffer.
-    ReplyBuffer.consume( ReplyBuffer.size() );
-
-    // Waiting for a reply. We prepare the buffer to receive up to 64KB.
-    Socket.async_receive(
-            ReplyBuffer.prepare( 65536 ),
-            boost::bind( &IcmpPinger::handle_receive_icmp_packet, this, _2 )
-    );
-}
-
 /**
  * @brief Gets called when the ping is finished: Either on timeout or on ping reply
  *
@@ -219,6 +207,18 @@ void IcmpPinger::handle_ping_done()
     PingDoneCallback(ping_success);
 }
 
+void IcmpPinger::start_receive()
+{
+    // Discard any data already in the buffer.
+    ReplyBuffer.consume( ReplyBuffer.size() );
+
+    // Waiting for a reply. We prepare the buffer to receive up to 64KB.
+    Socket.async_receive(
+            ReplyBuffer.prepare( 65536 ),
+            boost::bind( &IcmpPinger::handle_receive_icmp_packet, this, _2 )
+    );
+}
+
 /**
  * @brief Receive ICMP packets
  * Note: Will receive -all- ICMP packets from the kernel. So if the packet doesn't match
index 3c807f6..35cdef3 100644 (file)
@@ -55,10 +55,10 @@ private:
     IcmpPacket create_echo_request( const uint16_t sequence_number ) const;
     void send_echo_request( const IcmpPacket &icmp_packet );
     void schedule_timeout_echo_reply();
+    void handle_ping_done();
 
     void start_receive();
     void handle_receive_icmp_packet( const std::size_t &bytes_transferred );
-    void handle_ping_done();
 
     void print_echo_reply(
             const IcmpPacket &icmp_packet,