Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

programatic ping from C++

Posted on 1997-05-06
6
Medium Priority
?
890 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
[X]
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
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

670 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