I am trying to "ping" a remote host in my C++/Redhat Linux code to
check whether that host is connected or not.

if (0 == system("ping -w 2 192.168.0.2))


But, in both cases (connected/disconnected), system call returns 0. Can
someone please show what I am doing wrong? How to check the actual
result of the ping status using C++ on Redhat linux ?


Thanks in advance.