void ConvertErrorToString( DWORD error_code, CString& meaning ) const
DWORD Ping( const CString& name_or_address, CPingResults * results_p, short desired_time_to_live )
#include <wfc.h>
#pragma hdrstop
int _tmain( int number_of_command_line_arguments, TCHAR *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 );
}