Back to the WFC main page

CPingResults

$Revision: 22 $

Description

This class is filled in by CPing::Ping(). It contains the data gathered in the ping.

Constructors

CPingResults()
CPingResults( const CPingResults&   source )
CPingResults( const CPingResults *  source )
CPingResults( const IP_ECHO_REPLY&  source )
CPingResults( const IP_ECHO_REPLY * source )
Constructs the object.

Data Members

CString Address
The dotted IP address of the pinged host.
DWORD RoundTripTimeInMilliseconds
How many milliseconds it took for the packet to go and come back.
BYTE TimeToLive
Number of "hops"

Methods

void Copy( const CPingResults&   source )
void Copy( const CPingResults *  source )
void Copy( const IP_ECHO_REPLY&  source )
void Copy( const IP_ECHO_REPLY * source )
Copies other CPingResults classes or IP_ECHO_REPLY structures.
void Dump( CDumpContext& dump_context ) const
Present only in debug builds. Dumps the contents of this object to the dump_context.
void Empty( void )
Resets all data members to an emtpy state.

Example

#include <wfc.h>
#pragma hdrstop

int _tmain( int number_of_command_line_arguments, LPCTSTR command_line_arguments[] )
{
   WFCTRACEINIT( TEXT( "_tmain()" ) );

   CSimpleSocket::StartWindowsSockets();

   CPing ping;

   DWORD return_value = 0;

   CPingResults results;

   return_value = ping.Ping( TEXT( "20.2.1.3" ), &results );

   if ( return_value == 0 )
   {
      DWORD error_code = ping.GetErrorCode();

      CString error_message;

      ping.ConvertErrorToString( error_code, error_message );

      _tprintf( TEXT( "Ping Error: %s\n" ), (LPCTSTR) error_message );
   }
   else
   {
      _tprintf( TEXT( "Ping: %s Round Trip %lums TTL: %d\n" ),
                (LPCTSTR) results.Address,
                results.RoundTripTimeInMilliseconds,
                (int) results.TimeToLive );
   }

   CSimpleSocket::StopWindowsSockets();

   return( EXIT_SUCCESS );
}

Copyright, 2000, Samuel R. Blackburn
$Workfile: CPingRes.cpp $
$Modtime: 1/17/00 9:10a $