*/
void IcmpPinger::ping(
const string &destination_ip,
- const int /*destination_port*/, // the ICMP protocol does not use ports
+ const uint16_t /*destination_port*/, // the ICMP protocol does not use ports
function< void(bool) > ping_done_callback
)
{
{
boost::asio::streambuf request_buffer;
ostream os( &request_buffer );
- icmp_packet->write( os );
+ if ( !icmp_packet->write( os ) )
+ {
+ GlobalLogger.error() << "Error: fail writing ping data." << endl;
+ }
TimeSent = microsec_clock::universal_time();
{
// Check ReplyReceived as the timer handler
// is also called by Timer.cancel();
- if ( ReplyReceived == false )
+ if ( !ReplyReceived )
{
GlobalLogger.info() << "Request timed out" << endl;
*/
void TcpPinger::ping(
const string &destination_ip,
- const int destination_port,
+ const uint16_t destination_port,
function<void(bool)> ping_done_callback
)
{
BOOST_ASSERT( !destination_ip.empty() );
- BOOST_ASSERT( ( 0 <= destination_port ) && ( destination_port < numeric_limits<uint16_t>::max() ) );
+ BOOST_ASSERT( ( 0 < destination_port ) && ( destination_port < numeric_limits<uint16_t>::max() ) );
PingDoneCallback = ping_done_callback;
void TcpPinger::set_destination_endpoint(
const string &destination_ip,
- const int destination_port
+ const uint16_t destination_port
)
{
BOOST_ASSERT( !destination_ip.empty() );
- BOOST_ASSERT( ( 0 <= destination_port ) && ( destination_port <= numeric_limits<uint16_t>::max() ) );
+ BOOST_ASSERT( ( 0 < destination_port ) && ( destination_port < numeric_limits<uint16_t>::max() ) );
BOOST_STATIC_ASSERT( sizeof(uint16_t) <= sizeof(destination_port) );
address destination_address = address::from_string( destination_ip );
// Encode the request packet.
boost::asio::streambuf request_buffer;
ostream os( &request_buffer );
- tcp_segment->write( os );
+ if ( !tcp_segment->write( os ) )
+ {
+ GlobalLogger.error() << "Error: fail writing ping data." << endl;
+ }
TimeSent = microsec_clock::universal_time();
{
// Check ReceivedReply as the timer handler
// is also called by Timer.cancel();
- if ( ReceivedReply == false )
+ if ( !ReceivedReply )
{
GlobalLogger.info() << "Request timed out" << endl;