Solved

programatic ping from C++

Posted on 1997-05-06
6
877 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
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.

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now