From bd4da22bf280d01b601bfebc2c14b7ea007184ad Mon Sep 17 00:00:00 2001 From: Christian Herdtweck Date: Tue, 9 Dec 2014 16:02:36 +0100 Subject: [PATCH] replace magic number 64k with constant SOCKET_BUFFER_SIZE --- src/icmp/icmppinger.cpp | 4 ++-- src/icmp/icmppinger.h | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/icmp/icmppinger.cpp b/src/icmp/icmppinger.cpp index 6899c6b..4734026 100644 --- a/src/icmp/icmppinger.cpp +++ b/src/icmp/icmppinger.cpp @@ -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 ) ); } diff --git a/src/icmp/icmppinger.h b/src/icmp/icmppinger.h index a700f5f..3387388 100644 --- a/src/icmp/icmppinger.h +++ b/src/icmp/icmppinger.h @@ -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 @@ -23,6 +24,10 @@ // 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. -- 1.7.1