Hi all,
I am using the gethostbyname() function in the usual manner...
iaHost.s_addr = inet_addr(lpServerName);
if (iaHost.s_addr == INADDR_NONE)
{
// Wasn't an IP address string, assume it is a name
lpHostEntry = 0;
lpHostEntry = gethostbyname(lpServerName);
}
to access my web site and return information. The variable, "lpServerName", can be any host, e.g., "google.com" or the loop-back, "127.0.0.1".
My system: Windows x64 or x32 (it doesn't matter the same error occurs) running on an AMD Opteron system, XAMPP is on my machine and I use it for debugging purposes, my compiler is Microsoft Visual c++ 2005.
Here's the problem: when I use the loop-back address, the code above works fine. When I try and access a web site exterior to my computer I get the following error: "Windows has triggered a breakpoint in test_gethostbyname.exe. This may be due to a corruption of the heap, and indicates a bug in test_gethostbyname.exe or any of the DLLs it has loaded. The output window may have more diagnostic information". The program, "test_gethostbyname.exe", contains only the parts of the code from a much larger project that apply to accessing the internet. Thus, I don't think the heap is being corrupted by anything I have done. I have tried the "getaddrinfo" command with the same results. I have searched the web for any kind of information on this problem with no joy (other than segmentation faults on unix systems).
Does anyone know of any problem with this command that would cause this error to occur?
Thanks in advance,
Jay