Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C++
System("Ping") always returns 0
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Neel, post: 2544931"] Thanks a lot Larry for help. BUT, as I said, I would like to know the ping result (If I get a ping reply from remote host, its TRUE) and (if I don't get a ping reply from remote host, its FALSE). I used WEXITSTATUS(status) with remote host disconnected. I am still getting a TRUE. Please see below my code. sprintf(pingstring,"ping -w 2 %s",ip_add); // Execute 'ping' command via the system call status = system(pingstring); //lint !e421 function 'system(const char *)' is considered dangerous [MISRA Rule 126] PDEBUG("Ping returned status:%d", status); if (-1 != status) { ping_ret = WEXITSTATUS(status); PDEBUG("Ping WEXITSTATUS ping_ret:%d", ping_ret); if(0 == ping_ret) { result = TRUE; } } In both cases when remote host replys or doesn't reply, i get "ping_ret" as 0. Let me know what i am doing wrong here. Thanks for this stupid question [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
System("Ping") always returns 0
Top