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: 2544962"] 1) I did the same thing what you told me to do. #include <stdlib.h> #include <sys/types.h> #include <sys/wait.h> int ping_ret, status; status = system("ping -w 2 192.168.0.2"); if (-1 != status) ping_ret = WEXITSTATUS(status); But, even if ethernet cable is connected or not to the remote host, I always get "Ping_ret" = 0. 2) I also tried popen: char psBuffer[1024]; FILE * fdRTP; if( (fdRTP = popen( "ping -c 1 192.168.0.2", "r" )) == NULL ) { FSLog(LOG_ERROR, "AebEthernetTest::HandleDmseCommand(): Failed to create Pipe"); error_code = AEB_DPI_INIFILEREADERR; } else { /* Read this pipe and print to the stdout until end of file */ while( !feof( fdRTP ) ) { if( fread( psBuffer, sizeof(char), 1024, fdRTP ) ) { if(0 == strcmp(psBuffer,"0% loss")) { result = TRUE; } } } } /* Close pipe */ pclose( fdRTP ); But, in this case, its not even "Ping". I have also posted this question on comp.unix.programmer. Help me guys. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
System("Ping") always returns 0
Top