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?
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.
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
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.
Re: How to find Is another PC in the same network is alive from PC?
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.
Re: How to find Is another PC in the same network is alive from PC?
Quote:
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,
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...
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.
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,
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.
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,