-
March 5th, 2004, 03:02 AM
#1
Ping!!!!
Hi All,
I need to write a pgm to ping a system.
Also, i need to specify a timeout for that.
How to do that ?
Becoz most of the code to ping uses socket (even ICMP calls) commands like inet_addr.
Since these commands are used, when the system if not present takes a lot of time.
So how to write a pgm to ping a system by specifying Timeout?
With Regards,
A.Ilamparithi.
-
March 5th, 2004, 03:08 AM
#2
-
March 5th, 2004, 03:24 AM
#3
at least under win98 there is a DOS-commando ping that does almost everyhting you ask for. The only difficulty seems to analyze the results....
Maybe you just want to write a batch file?
just type "ping /?" in your DOS-box
Marc
-
March 5th, 2004, 04:48 AM
#4
Re:
Hi,
If you see at the above link, you can find an example like this
// Declare and initialize variables
char *SendData = "Data Buffer";
LPVOID ReplyBuffer;
ReplyBuffer = (VOID*) malloc(sizeof(ICMP_ECHO_REPLY) + sizeof(SendData));
if ((dwRetVal = IcmpSendEcho(hIcmpFile,
inet_addr("123.456.789.0"),
SendData, sizeof(SendData),
NULL, ReplyBuffer,
sizeof(ReplyBuffer) + sizeof(ICMP_ECHO_REPLY),
1000)) != 0) {
printf("\tReceived %ld messages.\n", dwRetVal);
printf("\tMessage: %s\n", ReplyBuffer);
}
else {
printf("\tCall to IcmpSendEcho() failed.\n");
printf("\tError: %ld\n", GetLastError());
}
Even If you specify TIME OUT in IcmpSendEcho, if the system is down(offline) you can notice that it will take more time. This is becoz of inet_addr call used there. If the system is offline, this call takes lot of time and is the reason for delay.
With Best Regards,
A.Ilamparithi.
-
March 5th, 2004, 05:35 AM
#5
eh? how long of a delay? The only thing that could cause it is a DNS lookup.
-
March 5th, 2004, 07:18 AM
#6
Re:
Originally posted by Mick
eh? how long of a delay? The only thing that could cause it is a DNS lookup.
Hi,
The delay is much larger. It is nearly 1.5 seconds.(in case of a offline system). But i want th timeout to be only 150 ms.
With Thanks,
A.Ilamparithi.
-
March 6th, 2004, 03:10 PM
#7
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|