Thread: failed with error 11004

  1. #1
    Registered User Rare177's Avatar
    Join Date
    May 2004
    Posts
    214

    failed with error 11004

    i have a winsock program that is in unicode and it is having problems resolving some ips/hostnames , i used get last error to get the error and i got this

    failed with error 11004: The request name is valid and was found in the database , but it does not have the correct associated data being resolved for

    would any one know why that is?

    heres the code
    Code:
    int ConnectAndSend(){
    
    unsigned short port = 9980;
    int retval = 0;
    struct sockaddr_in server;
    WSADATA wsaData;
    SOCKET conns;
    struct hostent *hp;
    unsigned int addr;
    TCHAR server_name[128];
    
    retval = WSAStartup(0x202, &wsaData);
    
    if (retval != 0){
      AppendWindowText(hwndRichEdit, _T("ERROR: Cannot load winsock DLL.\r\n"));
      return 1;
    }
    
    AppendWindowText(hwndRichEdit, _T("> Winsock DLL loaded.\r\n"));
    
    SendMessage(hwndIPEdit, WM_GETTEXT, (WPARAM)ARRAYSIZE(server_name), (LPARAM)server_name);
    if (SendMessage(hwndIPEdit, WM_GETTEXT, (WPARAM)ARRAYSIZE(server_name), (LPARAM)server_name))
    {
    	char server_nameA[128];
    
    	// Convert down to ansi...
    	TToAnsi(server_name, server_nameA, ARRAYSIZE(server_nameA));
    
    	// Now use the A version where needed...
    	if (isalpha(server_nameA[0]))
    	{
    		hp = gethostbyname(server_nameA);
    	}
    	else
    	{
    		addr = inet_addr(server_nameA);
    		hp = gethostbyaddr((const char *) &addr, 4, AF_INET);
    	}
    
    if (hp == NULL){
      ErrorExit(hp);
      AppendWindowText(hwndRichEdit, _T("Can't resolve IP/Hostname. Please make sure it is correct.\r\n"));
      WSACleanup();
      return 1;
    }

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Print out the value of the server_nameA variable to see what your program is working with.
    Determine if you're using gethostbyname or byaddr (ie be sure which way your code is branching.)
    It's possible that the DNS server answering your question cannot find a hostname for the given IP.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    >> It's possible that the DNS server answering your question cannot find a hostname for the given IP. <<

    To check this:

    - Go to Network tools DNS lookup tool.
    - Select "A - Address" for query type and type in your target server.
    - Make sure at least one record with type "A" comes up.
    - Post the DNS lookup output if you're still having trouble.


    Quote Originally Posted by MSDN
    Valid name, no data record of requested type.
    The requested name is valid and was found in the database, but it does not have the correct associated data being resolved for. The usual example for this is a host name-to-address translation attempt (using gethostbyname or WSAAsyncGetHostByName) which uses the DNS (Domain Name Server). An MX record is returned but no A record—indicating the host itself exists, but is not directly reachable.
    Last edited by anonytmouse; 07-10-2004 at 01:32 PM.

  4. #4
    Registered User Rare177's Avatar
    Join Date
    May 2004
    Posts
    214
    i did that with yahoo as the domain and got this

    DNS query for yahoo.com failed: Connection reset

    it happens with a few ip..

    could there be a better alternative to A server?

  5. #5
    Registered User
    Join Date
    Jul 2004
    Posts
    17
    The same thing is happening to me, execpt I'm not using unicode and I'm only using the gethostbyaddr().

  6. #6
    Registered User
    Join Date
    Jul 2004
    Posts
    17
    I figured out my problem, when i use gethostbyname() it works fine

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. "Virtual Printer" or "Moving Printjobs"
    By extasic in forum Windows Programming
    Replies: 12
    Last Post: 06-30-2011, 08:33 AM
  2. addrinfo Structure Not Working
    By pobri19 in forum Networking/Device Communication
    Replies: 9
    Last Post: 10-22-2008, 10:07 AM
  3. Thread Prog in C language (seg fault)
    By kumars in forum C Programming
    Replies: 22
    Last Post: 10-09-2008, 01:17 PM
  4. C++ text file
    By statquos in forum C++ Programming
    Replies: 7
    Last Post: 06-12-2008, 01:42 PM
  5. gethostbyaddr() reverse lookups failing (???)
    By Uncle Rico in forum C Programming
    Replies: 9
    Last Post: 08-19-2005, 09:22 AM