none
"The RPC Server Is Unavailable" when executing gethostbyname() RRS feed

  • 質問

  • What are the most probable reasons for getting "The RPC Server Is Unavailable" when I execute gethostbyname() ?  If I hit continue in the debugger everything appears to work fine.  I am using Visual Studio 2008 with C++.
    2009年7月5日 17:37

回答

すべての返信

  • I'd guess at Tools + Options, Debugger, Native, Enable RPC debugging checkbox.  Post your code if that doesn't help.

    Hans Passant.
    • 回答としてマーク Wesley Yao 2009年7月13日 2:34
    2009年7月5日 21:07
    モデレータ
  • Totally late to the party but I came across this issue today myself. My particular cause was that the "DNS Client" service was stopped. Once I started the service the following code ceased to get RPC Server Unavailable errors:

        static    WORD    wVersionRequested = 0;
        WSADATA    wsaData;
        wVersionRequested = MAKEWORD( bVersion, bRevision );
        int iReturn = WSAStartup(wVersionRequested, &wsaData);
        hostent*    lphostent = gethostbyname("social.msdn.microsoft.com");

    Stopping that service again restores said error (which is a nasty error because when it happens it leads to an eventually (again in my case) to:

    • First-chance exception at 0x00000001 in IPForward.exe: 0xC0000005: Access violation.

    Which a pretty serious f**k up for a stopped service. Strange how it only makes developer code look bad, the OS doesn't seem to suffer from this (then I guess MS do state in their documentation:

    "Note  The gethostbyname function has been deprecated by the introduction of the getaddrinfo function. Developers creating Windows Sockets 2 applications are urged to use the getaddrinfo function instead of gethostbyname. )."

    The above code is valid though and really shouldn't crash the whole process when run.


    Kind Regards, V Website: http://www.kvkconsultancy.co.uk


    2019年5月30日 8:52