Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

programatic ping from C++

Posted on 1997-05-06
6
Medium Priority
?
892 Views
Last Modified: 2008-03-10
How can you do a ping programatically from Visual C++ 4.1 using winsock ? Is there any other way of doing this without winsock ?
0
Comment
Question by:kandalai
  • 3
  • 3
6 Comments
 

Accepted Solution

by:
prade earned 100 total points
ID: 1163309
Consider executing ping via a shell call from within your
program. Or you might port the UNIX sources of ping to WIndows.
(Wich shouldn't be too much work)

0
 

Author Comment

by:kandalai
ID: 1163310
Thanks for the suggestion. But I can't really use the shell command. That's what I mean by 'ping programatically'. I have to do it using winsock from Visual C++, creating asynchronous sockets. This is all to know if a remote machine is up or down. I can attach my source code if you are interested. Please let me know.
0
 

Expert Comment

by:prade
ID: 1163311
if you only need to check if a machine is up, it would be enough to just try to connect to its ping port.
If the connection is refused, that machine is propably down.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:kandalai
ID: 1163312
Is the ping port on all machines is the same as FTP etc. Can I make a socket and try connect to this port on the remote machine
and see if it lets me do that ? If so what standard ping port number I have to use while connecting ? Does it have to be a stream socket ? How does the whole thing work if connection less sockets (SOCK_DGRAM) are used ? Any literature or code available on this ? I appreciate your help. Thank You
0
 

Expert Comment

by:prade
ID: 1163313
yes you can. use the echo port
(not "ping port", ping uses something else than udp/tcp)
the echo port number is 7
(also to be found in your /etc/services)
you can use either stream or dgram sockets (tcp or udp)
it shouldn't matter.
0
 

Author Comment

by:kandalai
ID: 1163314
Thank you very much. I will try this.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question