IcmpSendEcho error: 1231
-
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
-
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
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
-
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
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
-
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
yes
Future Lies in Present. Manmohan Bishnoi
-
yes
Future Lies in Present. Manmohan Bishnoi
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
-
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
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
-
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
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