-
June 16th, 2009, 06:03 AM
#1
How to find PC2 is pinging successfully from a PC1 in a LAN? Any inbuilt function?
Hai all,
I'm using VC++6.0
Scope of problem:
PC1 wants to continuosly checking PC2's Ethernet Status, Whether PC2 is connected to the Network or not.
I have found one function.
IsDestinationReachable(IPAddress,lpQOCInfo)...
but is not identifing when the ethernet cable is plugged of from PC2.
May i know why?
Is there any other function available to find it?
Last edited by hotsaravana; June 17th, 2009 at 07:54 AM.
Reason: I have changed the sentence of "Title" block to make more understand
-
June 17th, 2009, 01:35 AM
#2
Re: How to find Is another PC in the same network is alive from PC?
If you have file sharing enabled between two PCs then you can try to access a folder on another machine like this:
\\server\share\folder_path
For that you can use any API that takes the above line, say GetFileAttributes() and check the error returned by GetLastError() if any.
-
June 17th, 2009, 07:30 AM
#3
Re: How to find Is another PC in the same network is alive from PC?
Hi...
No.. but I didn't need any files or shared folder kind of that.
Rather I need to check the Ethernet status alone..
Is it possible with any other function?
Suppose a Ethernet of the PC1 has gone... PC1 can detect itself by using
IsNetworkAlive(), likewise IS there any other functions supporting to that?
With regards,
Saravana
-
June 17th, 2009, 10:38 AM
#4
Re: How to find Is another PC in the same network is alive from PC?
Try using Sockets, they are designed for networking developement. I believe you can also access the MAC ADRESS and interegate the network card.
-
June 17th, 2009, 10:50 AM
#5
Re: How to find Is another PC in the same network is alive from PC?
-
June 17th, 2009, 11:27 PM
#6
Re: How to find Is another PC in the same network is alive from PC?
Ya.. I was usually try with CSocket. But do they offer any functions to find my needs out?
Sorry I'm a beginner to Network programming.
-
June 17th, 2009, 11:36 PM
#7
Re: How to find Is another PC in the same network is alive from PC?
Originally Posted by hotsaravana
Hi...
Suppose a Ethernet of the PC1 has gone... PC1 can detect itself by using
IsNetworkAlive(), likewise IS there any other functions supporting to that?
With regards,
Saravana
Have a look at "IcmpSendEcho()" API... It seems to be helpful for you....
Hope this helps
Thanks,
-
June 18th, 2009, 05:05 AM
#8
Re: How to find Is another PC in the same network is alive from PC?
Ya. I have tried with IcmpSendEcho() function.
It shows errors like this.. when i'm tring to execute the sample program.
c:\program files\microsoft visual studio\vc98\include\icmpapi.h(175) : error C2061: syntax error : identifier 'IPAddr'
c:\program files\microsoft visual studio\vc98\include\icmpapi.h(264) : error C2061: syntax error : identifier 'IPAddr'
c:\program files\microsoft visual studio\vc98\include\icmpapi.h(288) : error C2061: syntax error : identifier 'PIP_OPTION_INFORMATION'
C:\Documents and Settings\saravanamuthu\Desktop\Client & Server POC\Client & Server POC\Server\MainFrm.cpp(188) : error C2660: 'IcmpSendEcho' : function does not take 8 parameters
But it actually takes only 8 parameters, like that only its specified in it?
kindly help me out...
-
June 18th, 2009, 06:25 AM
#9
Re: How to find Is another PC in the same network is alive from PC?
Make sure to include Icmpapi.h and add Iphlpapi.lib to your project settings.
-
June 18th, 2009, 07:04 AM
#10
Re: How to find Is another PC in the same network is alive from PC?
Here is an E.g code snippet:
Code:
char SendData[] = "Data Buffer";
LPVOID ReplyBuffer;
DWORD dwRetVal = 0;
...
HANDLE hIcmpFile = NULL;
hIcmpFile = IcmpCreateFile();
...check if opened successfully...Don't forget to close with IcmpCloseHandle(hIcmpFile) after using it.
...
ReplyBuffer = (VOID*) malloc(sizeof(ICMP_ECHO_REPLY) + strlen(SendData) + 1);
DWORD buflen;
buflen = sizeof(ICMP_ECHO_REPLY) + strlen(SendData) + 1;
if ((dwRetVal = IcmpSendEcho(hIcmpFile,
inet_addr(_T("192.168.200.140")),
SendData,
strlen(SendData),
NULL,
ReplyBuffer,
buflen,
1000)) != 0)
}
Hope this helps,
Thanks,
-
June 18th, 2009, 08:21 AM
#11
Re: How to find Is another PC in the same network is alive from PC?
Thanks in advance.
Actually I had one doubt,
In my Visual Studio 6.0, there is no such header files or library files.
So, I just copied that files from the Visual Studio 2005.net system and attempt to run it? I know this is not the right way to do. can u suggest any way? Is those files are got from any where?
I thought these errors are occured, only becoz i have copied from VS2005.Net. I think so.
Suggest me some way to get it out.
-
June 18th, 2009, 11:25 PM
#12
Re: How to find Is another PC in the same network is alive from PC?
You need to install Microsoft Platform SDK for Windows on your system to get those files.
Thanks,
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
|