Hi!
Does anyone know, how to capture ping's return value in c++? According to this link:
ping should return 0
on success, 1
on failure such as unknown host, illegal packet size, etc. and 2
On a unreachable host or network.
In C++ I called ping with the system ()
, e.g. int ret = system("ping 192.168.1.5");
.
My problem is, that ret
's value is 0
or 1
. It will never 2
! If I think correctly, this is because, this return value I get, is the system functions return value, not ping's. So how could i get ping's return vlaue?
Thanks in advance!
kampi
Edit: Right now i use this system("ping 192.169.1.5 > ping_res.txt"); but i don't want to work with files (open, and read them), that's why i want to capture, th return value , if possible :)