Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. IcmpSendEcho error: 1231

IcmpSendEcho error: 1231

Scheduled Pinned Locked Moved C / C++ / MFC
helpsysadmin
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Manmohan29
    wrote on last edited by
    #1

    I got 1231 error value when using the code below. 1231: The network location cannot be reached. For information about network troubleshooting, see Windows Help. my lan and internet is working fine. then where is actually the problem residing.

    HANDLE hIcmpFile;
    unsigned long ipaddr = INADDR_NONE;
    DWORD dwRetVal = 0;
    char SendData[] = "Data Buffer";
    LPVOID ReplyBuffer = NULL;
    DWORD ReplySize = 0;

    ipaddr = inet_addr((const char*)m_sAddress);
    ReplySize = sizeof(ICMP_ECHO_REPLY) + sizeof(SendData) +1;
    ReplyBuffer = (VOID*)malloc(ReplySize);

    hIcmpFile = IcmpCreateFile();
    if (hIcmpFile == INVALID_HANDLE_VALUE)
    {
    return -1;
    }
    dwRetVal = IcmpSendEcho(hIcmpFile, ipaddr, SendData, sizeof(SendData) + sizeof(ICMP_ECHO_REPLY), NULL, ReplyBuffer, ReplySize, 500);
    if(dwRetVal != 0)
    {
    PICMP_ECHO_REPLY pEchoReply = (PICMP_ECHO_REPLY)ReplyBuffer;
    struct in_addr ReplyAddr;
    ReplyAddr.S_un.S_addr = pEchoReply->Address;

    	m\_sMessage.Format(\_T("Received from %s Status = %ld RoundTripTime = %ld"), inet\_ntoa(ReplyAddr), pEchoReply->Status, pEchoReply->RoundTripTime);
    	return 0;
    }
    

    Future Lies in Present. Manmohan Bishnoi

    S D 2 Replies Last reply
    0
    • M Manmohan29

      I got 1231 error value when using the code below. 1231: The network location cannot be reached. For information about network troubleshooting, see Windows Help. my lan and internet is working fine. then where is actually the problem residing.

      HANDLE hIcmpFile;
      unsigned long ipaddr = INADDR_NONE;
      DWORD dwRetVal = 0;
      char SendData[] = "Data Buffer";
      LPVOID ReplyBuffer = NULL;
      DWORD ReplySize = 0;

      ipaddr = inet_addr((const char*)m_sAddress);
      ReplySize = sizeof(ICMP_ECHO_REPLY) + sizeof(SendData) +1;
      ReplyBuffer = (VOID*)malloc(ReplySize);

      hIcmpFile = IcmpCreateFile();
      if (hIcmpFile == INVALID_HANDLE_VALUE)
      {
      return -1;
      }
      dwRetVal = IcmpSendEcho(hIcmpFile, ipaddr, SendData, sizeof(SendData) + sizeof(ICMP_ECHO_REPLY), NULL, ReplyBuffer, ReplySize, 500);
      if(dwRetVal != 0)
      {
      PICMP_ECHO_REPLY pEchoReply = (PICMP_ECHO_REPLY)ReplyBuffer;
      struct in_addr ReplyAddr;
      ReplyAddr.S_un.S_addr = pEchoReply->Address;

      	m\_sMessage.Format(\_T("Received from %s Status = %ld RoundTripTime = %ld"), inet\_ntoa(ReplyAddr), pEchoReply->Status, pEchoReply->RoundTripTime);
      	return 0;
      }
      

      Future Lies in Present. Manmohan Bishnoi

      S Offline
      S Offline
      Sternocera
      wrote on last edited by
      #2

      If you want to use ping from your application, have a look at boost::asio. Boost have a ping example program that you may be able to adopt. Note that your application requires administrative privileges on Vista to create ICMP packets. Regards, Sternocera

      1 Reply Last reply
      0
      • M Manmohan29

        I got 1231 error value when using the code below. 1231: The network location cannot be reached. For information about network troubleshooting, see Windows Help. my lan and internet is working fine. then where is actually the problem residing.

        HANDLE hIcmpFile;
        unsigned long ipaddr = INADDR_NONE;
        DWORD dwRetVal = 0;
        char SendData[] = "Data Buffer";
        LPVOID ReplyBuffer = NULL;
        DWORD ReplySize = 0;

        ipaddr = inet_addr((const char*)m_sAddress);
        ReplySize = sizeof(ICMP_ECHO_REPLY) + sizeof(SendData) +1;
        ReplyBuffer = (VOID*)malloc(ReplySize);

        hIcmpFile = IcmpCreateFile();
        if (hIcmpFile == INVALID_HANDLE_VALUE)
        {
        return -1;
        }
        dwRetVal = IcmpSendEcho(hIcmpFile, ipaddr, SendData, sizeof(SendData) + sizeof(ICMP_ECHO_REPLY), NULL, ReplyBuffer, ReplySize, 500);
        if(dwRetVal != 0)
        {
        PICMP_ECHO_REPLY pEchoReply = (PICMP_ECHO_REPLY)ReplyBuffer;
        struct in_addr ReplyAddr;
        ReplyAddr.S_un.S_addr = pEchoReply->Address;

        	m\_sMessage.Format(\_T("Received from %s Status = %ld RoundTripTime = %ld"), inet\_ntoa(ReplyAddr), pEchoReply->Status, pEchoReply->RoundTripTime);
        	return 0;
        }
        

        Future Lies in Present. Manmohan Bishnoi

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        Manmohan29 wrote:

        I got 1231 error value when using the code below.

        From GetLastError()?

        "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        M 1 Reply Last reply
        0
        • D David Crow

          Manmohan29 wrote:

          I got 1231 error value when using the code below.

          From GetLastError()?

          "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          M Offline
          M Offline
          Manmohan29
          wrote on last edited by
          #4

          yes

          Future Lies in Present. Manmohan Bishnoi

          D 1 Reply Last reply
          0
          • M Manmohan29

            yes

            Future Lies in Present. Manmohan Bishnoi

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            Do you get that error for all addresses?

            "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

            "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

            M 1 Reply Last reply
            0
            • D David Crow

              Do you get that error for all addresses?

              "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

              "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

              M Offline
              M Offline
              Manmohan29
              wrote on last edited by
              #6

              yes same for all IP's. My OS is Windows Seven RC. I have also tested this on XP. There also the problem is same.

              Future Lies in Present. Manmohan Bishnoi

              D 1 Reply Last reply
              0
              • M Manmohan29

                yes same for all IP's. My OS is Windows Seven RC. I have also tested this on XP. There also the problem is same.

                Future Lies in Present. Manmohan Bishnoi

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #7

                I suggest you try others examples from here.

                "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

                "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups