Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

programatic ping from C++

Posted on 1997-05-06
6
883 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 50 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

839 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