CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12
  1. #1
    Join Date
    Sep 2008
    Posts
    63

    Unhappy 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

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    894

    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.

  3. #3
    Join Date
    Sep 2008
    Posts
    63

    Unhappy 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

  4. #4
    Join Date
    Apr 2009
    Posts
    57

    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.

  5. #5
    Join Date
    Apr 2009
    Posts
    57

    Re: How to find Is another PC in the same network is alive from PC?


  6. #6
    Join Date
    Sep 2008
    Posts
    63

    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.

  7. #7
    Join Date
    Aug 2008
    Location
    India
    Posts
    186

    Re: How to find Is another PC in the same network is alive from PC?

    Quote Originally Posted by hotsaravana View Post
    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,

  8. #8
    Join Date
    Sep 2008
    Posts
    63

    Exclamation 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...

  9. #9
    Join Date
    Aug 2008
    Location
    India
    Posts
    186

    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.

  10. #10
    Join Date
    Aug 2008
    Location
    India
    Posts
    186

    Thumbs up 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,

  11. #11
    Join Date
    Sep 2008
    Posts
    63

    Exclamation 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.

  12. #12
    Join Date
    Aug 2008
    Location
    India
    Posts
    186

    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
  •  





Click Here to Expand Forum to Full Width

Featured