replace magic number 64k with constant SOCKET_BUFFER_SIZE
authorChristian Herdtweck <christian.herdtweck@intra2net.com>
Tue, 9 Dec 2014 15:02:36 +0000 (16:02 +0100)
committerChristian Herdtweck <christian.herdtweck@intra2net.com>
Tue, 9 Dec 2014 15:02:36 +0000 (16:02 +0100)
src/icmp/icmppinger.cpp
src/icmp/icmppinger.h

index 6899c6b..4734026 100644 (file)
@@ -210,9 +210,9 @@ void IcmpPinger::start_receive()
         GlobalLogger.debug() << "consuming unused " << ReplyBuffer.size() << "bytes!" << endl;
     ReplyBuffer.consume( ReplyBuffer.size() );
 
-    // Waiting for a reply. We prepare the buffer to receive up to 64KB.
+    // Waiting for a reply, We prepare the buffer to receive up to SOCKET_BUFFER_SIZE bytes
     Socket.async_receive(
-            ReplyBuffer.prepare( 65536 ),
+            ReplyBuffer.prepare( SOCKET_BUFFER_SIZE ),
             boost::bind( &IcmpPinger::handle_receive_icmp_packet, this, _2 )
     );
 }
index a700f5f..3387388 100644 (file)
@@ -1,5 +1,6 @@
 // Boost pinger (c) 2011 by Guilherme Maciel Ferreira / Intra2net AG
 // Based upon work copyright (c) 2003-2010 Christopher M. Kohlhoff (ping.cpp)
+// Modified 2014 by Christian Herdtweck, Intra2net AG
 //
 // Distributed under the Boost Software License, Version 1.0.
 //    (See accompanying file LICENSE_1_0.txt or copy at
 // IcmpPinger
 //-----------------------------------------------------------------------------
 
+
+/// size of buffer used to read from socket in [bytes]
+const std::size_t SOCKET_BUFFER_SIZE = 65536;   // 64kB
+
 /**
  * @brief This class performs an ICMP ping to host using Boost Asio.
  * Scope: one object per host.