Returns a boolean indicating if the ping was successful or not.
authorGuilherme Maciel Ferreira <guilherme.maciel.ferreira@intra2net.com>
Tue, 15 Mar 2011 11:25:35 +0000 (12:25 +0100)
committerGuilherme Maciel Ferreira <guilherme.maciel.ferreira@intra2net.com>
Tue, 15 Mar 2011 11:29:12 +0000 (12:29 +0100)
src/ping/boostpinger.cpp
src/ping/boostpinger.h
src/ping/pinger.h

index 53df900..a61f1ea 100644 (file)
@@ -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()
index e57c0fe..f72fac5 100644 (file)
@@ -20,7 +20,7 @@ public:
     );
     virtual ~BoostPinger();
 
-    void ping( const std::string &destination );
+    bool ping( const std::string &destination );
 
 private:
     enum PingStatus {
index 3d1035c..a477f00 100644 (file)
@@ -13,7 +13,7 @@ public:
     Pinger();
     virtual ~Pinger();
 
-    virtual void ping( const std::string &destination ) = 0;
+    virtual bool ping( const std::string &destination ) = 0;
 
 };