Hi Guys

is there a way to incorparate the ping function into a app what i want to do is when the user trys to connect it opens a window and displays

1, pinging "ipaddress"
and if succesfull displays connecting to host ie "ipadress" from above
but if no ping return says connection failed

but i dont know how to do this could someone point me in the right direction please


std::cin >> ipadd;
commandArg = "ping " + ipadd.c_str();

Something along those lines should do you nicely. c_str() is in the string header btw.


Hi Freaky_Chris

thanks for the answer sir so after that runs i need to add a if and else statement on the result ?

what i plan on doing is have a ebox with the ipaddress and a button that says connect after that the window with pining ipaddress and if pinged a button ok becomes active if no ping then text saying connection failed.

also is there a better way of doing it?


You could redirect it to a text file, and then read the text file or examine pipes.

system("ping anipaddress > %TEMP%textfile.txt")

Then read the text file. thats the simpler option the better option would probably be pipes.



thanks for the answers i will look into the pipe method (google is friend :))
but for now i think the ping method should work out ok


This question has already been answered. Start a new discussion instead.