ping to check connection

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Dec 2007
Posts: 7
Reputation: maori is an unknown quantity at this point 
Solved Threads: 0
maori maori is offline Offline
Newbie Poster

ping to check connection

 
0
  #1
Oct 16th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 671
Reputation: Freaky_Chris is a jewel in the rough Freaky_Chris is a jewel in the rough Freaky_Chris is a jewel in the rough 
Solved Threads: 113
Freaky_Chris's Avatar
Freaky_Chris Freaky_Chris is offline Offline
Practically a Master Poster

Re: ping to check connection

 
0
  #2
Oct 16th, 2008
  1. std::cin >> ipadd;
  2. commandArg = "ping " + ipadd.c_str();
  3. system(commandArg);

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

Chris
Knowledge is power -- But experience is everything
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 7
Reputation: maori is an unknown quantity at this point 
Solved Threads: 0
maori maori is offline Offline
Newbie Poster

Re: ping to check connection

 
0
  #3
Oct 17th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 671
Reputation: Freaky_Chris is a jewel in the rough Freaky_Chris is a jewel in the rough Freaky_Chris is a jewel in the rough 
Solved Threads: 113
Freaky_Chris's Avatar
Freaky_Chris Freaky_Chris is offline Offline
Practically a Master Poster

Re: ping to check connection

 
0
  #4
Oct 17th, 2008
You could redirect it to a text file, and then read the text file or examine pipes.

  1. system("ping anipaddress > %TEMP%textfile.txt")
Then read the text file. thats the simpler option the better option would probably be pipes.

Chris
Knowledge is power -- But experience is everything
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 7
Reputation: maori is an unknown quantity at this point 
Solved Threads: 0
maori maori is offline Offline
Newbie Poster

Re: ping to check connection

 
0
  #5
Oct 18th, 2008
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
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC