From: Guilherme Maciel Ferreira Date: Tue, 15 Mar 2011 11:25:35 +0000 (+0100) Subject: Returns a boolean indicating if the ping was successful or not. X-Git-Tag: v1.0~139 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=9611d5d5db6a3af1c907c5f2f7266eeba0618a10;p=pingcheck Returns a boolean indicating if the ping was successful or not. --- diff --git a/src/ping/boostpinger.cpp b/src/ping/boostpinger.cpp index 53df900..a61f1ea 100644 --- a/src/ping/boostpinger.cpp +++ b/src/ping/boostpinger.cpp @@ -48,10 +48,13 @@ BoostPinger::~BoostPinger() * * @param destination The address of the host where to ping. * + * @return true if the ping was successfully performed, or false if the ping + * was not replied due timeout. + * * @note This method is synchronous, i.e. this method blocks and returns only * after the ping requested has finished or timed-out. */ -void BoostPinger::ping( const string &destination ) +bool BoostPinger::ping( const string &destination ) { BOOST_ASSERT( !destination.empty() ); @@ -59,6 +62,9 @@ void BoostPinger::ping( const string &destination ) DestinationEndpoint = *Resolver.resolve( query ); start_pinger(); + + bool ping_success = (PingerStatus == PingStatus_SuccessReply); + return ping_success; } void BoostPinger::start_pinger() diff --git a/src/ping/boostpinger.h b/src/ping/boostpinger.h index e57c0fe..f72fac5 100644 --- a/src/ping/boostpinger.h +++ b/src/ping/boostpinger.h @@ -20,7 +20,7 @@ public: ); virtual ~BoostPinger(); - void ping( const std::string &destination ); + bool ping( const std::string &destination ); private: enum PingStatus { diff --git a/src/ping/pinger.h b/src/ping/pinger.h index 3d1035c..a477f00 100644 --- a/src/ping/pinger.h +++ b/src/ping/pinger.h @@ -13,7 +13,7 @@ public: Pinger(); virtual ~Pinger(); - virtual void ping( const std::string &destination ) = 0; + virtual bool ping( const std::string &destination ) = 0; };