Hot Door CORE  0.7.0
Adobe® Illustrator® Plug-in Library
Public Member Functions | Static Public Member Functions | List of all members
hdi::core::InternetPing Class Reference

Allows for the creation of simple ICMP ping clients to check the availability of a remote host. More...

#include <hdicoreInternetPing.h>

Public Member Functions

 InternetPing (const std::string &domain_, const Callback &success_, const Callback &failure_)
 Creates a synchronous (blocking) InternetPing object to perform a ping request. More...
 
virtual ~InternetPing ()
 Destructs an InternetPing object. More...
 
virtual bool asynchronous () const
 Gets whether the target object is asynchronous (i.e. executes in a background thread) More...
 
virtual void run ()
 Starts the ping request. More...
 
virtual bool running () const
 Gets whether the ping request is currently running. More...
 
virtual bool reached () const
 Gets whether the remote host was reached when pinged. More...
 
virtual double timing () const
 Gets how long it took to reach the remote host. More...
 
virtual std::string address () const
 Gets the IP address of the remote host for the domain given when the InternetPing object was constructed. More...
 
virtual std::string error () const
 Gets an error description if the ping request failed. More...
 

Static Public Member Functions

static InternetPingAsync (const std::string &domain_, const Callback &success_, const Callback &failure_)
 Creates an asynchronous (non-blocking) InternetPing object to perform a ICMP ping request. More...
 

Detailed Description

Allows for the creation of simple ICMP ping clients to check the availability of a remote host.

Note
All pings have a time-to-live of 60 seconds.

Constructor & Destructor Documentation

hdi::core::InternetPing::InternetPing ( const std::string &  domain_,
const Callback success_,
const Callback failure_ 
)

Creates a synchronous (blocking) InternetPing object to perform a ping request.

Author
GW
Date
03/2017
Parameters
domain_Domain name to ping, as UTF-8
success_Callback to perform when the request completes successfully
failure_Callback to perform when the request fails
Note
The callbacks will not be called if their scheduling comes during or after plugin pre-shutdown (this would lead to a crash on quit).
virtual hdi::core::InternetPing::~InternetPing ( )
virtual

Destructs an InternetPing object.

Author
GW
Date
03/2017

Member Function Documentation

virtual std::string hdi::core::InternetPing::address ( ) const
virtual

Gets the IP address of the remote host for the domain given when the InternetPing object was constructed.

Author
GW
Date
03/2017
Returns
The IPv4 or IPv6 address of the host (whichever was actually used for the ping), or "" if the host was not reached at all
Note
The results of this method are only valid when it is called from the "success" callback (see the InternetPing constructor).
static InternetPing* hdi::core::InternetPing::Async ( const std::string &  domain_,
const Callback success_,
const Callback failure_ 
)
static

Creates an asynchronous (non-blocking) InternetPing object to perform a ICMP ping request.

Author
GW
Date
03/2017
Parameters
domain_Domain name to ping, as UTF-8
success_Callback to perform when the request completes successfully
failure_Callback to perform when the request fails
Warning
The responsibility for the memory of the returned InternetPing pointer lies with the caller, and it must not be deleted until after either the success or failure callbacks are called.
Note
Asynchronous InternetPing objects must be allocated using operator new (only synchronous InternetPing objects can be allocated on the stack), which this function does automatically.
The callbacks will not be called if their scheduling comes during or after plugin pre-shutdown (this would lead to a crash on quit).
virtual bool hdi::core::InternetPing::asynchronous ( ) const
virtual

Gets whether the target object is asynchronous (i.e. executes in a background thread)

Author
GW
Date
03/2017
Returns
true for asynchronous, false for synchronous
virtual std::string hdi::core::InternetPing::error ( ) const
virtual

Gets an error description if the ping request failed.

Author
GW
Date
03/2017
Returns
The resultant error of the request, as UTF-8
Note
The results of this method are only valid when it is called from the "failure" callback (see the InternetPing constructor).
virtual bool hdi::core::InternetPing::reached ( ) const
virtual

Gets whether the remote host was reached when pinged.

Author
GW
Date
03/2017
Returns
true if the remote host was reached, false otherwise
Note
The results of this method are only valid when it is called from the "success" callback (see the InternetPing constructor).
virtual void hdi::core::InternetPing::run ( )
virtual

Starts the ping request.

Author
GW
Date
03/2017
virtual bool hdi::core::InternetPing::running ( ) const
virtual

Gets whether the ping request is currently running.

Author
GW
Date
03/2017
Returns
true if the request is running, false otherwise
virtual double hdi::core::InternetPing::timing ( ) const
virtual

Gets how long it took to reach the remote host.

Author
GW
Date
03/2017
Returns
Total round-trip time, in seconds, to reach the host, or -1.0 if the host was not reached at all
Note
The results of this method are only valid when it is called from the "success" callback (see the InternetPing constructor).