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

TIA

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

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

Chris

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?

TIA

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.

Chris

heya

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

thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.