Note that there are some explanatory texts on larger screens.

plurals
  1. POWSAGetLastError with unknown error code
    text
    copied!<p>I am using WSAGetLastError function to retrieve failure details when using getHostByName function. But the error code returned by the function is 0042124C is not available in the documentation. Am I receiving the error code in some other format or am I using the function in a faulty way?</p> <p>Thanks.</p> <p>PS. Code segment below</p> <pre><code>// DNS Hostname.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "DNS Hostname.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // The one and only application object CWinApp theApp; using namespace std; int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) { int nRetCode = 0; // initialize MFC and print and error on failure if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0)) { // TODO: change error code to suit your needs cerr &lt;&lt; _T("Fatal Error: MFC initialization failed") &lt;&lt; endl; nRetCode = 1; } else { WORD wVersionRequested; WSADATA wsaData; int err; wVersionRequested = MAKEWORD(2, 2); err = WSAStartup(wVersionRequested, &amp;wsaData); HOSTENT* pHostDetails = NULL; pHostDetails = gethostbyname("IE10-FLYFB1S"); if(pHostDetails) { int nList = 0; CString sAddressString; CString sSQLAddress; CString sSQLMachine; unsigned long addr; while ( pHostDetails-&gt;h_addr_list[nList] ) { addr = (*(u_long FAR *) pHostDetails-&gt;h_addr_list[nList]); sAddressString.Format(_T("%d.%d.%d.%d"),(addr &amp; 255),((addr &gt;&gt; 8) &amp; 255),((addr &gt;&gt; 16) &amp; 255),((addr &gt;&gt; 24) &amp; 255)); sSQLAddress.Format(_T(" OR Machine = '%s' "),sAddressString); sSQLMachine += sSQLAddress; nList++; } cout &lt;&lt; sSQLMachine &lt;&lt; endl; } else { int error = WSAGetLastError(); cout &lt;&lt; error &lt;&lt; endl; } } WSACleanup(); return nRetCode; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload