-
March 26th, 2006, 06:56 AM
#1
Problem using Winsock 2.2 when host can't be resolved to a hostname
EDIT: I just read you dont need to resolve an address in order to connect? is this correct? my knowledge of winsock in limited
I’m having problems with the tutorial on Winsock over here: http://www.hal-pc.org/~johnnie2/winsock.html
The problem I believe is that the host does not have a DNS entry (??), and therefore Winsock get confused and believes that the host is not up.
The Winsock error I’m getting is:
Socket error 11004 - Valid name, no data record of requested type
Another description I found was :
“In most cases, this error means that the specified Host cannot be resolved. Make sure Host is assigned a valid and existing host address. This error may also mean a problem with your network and/or DNS.”
This works fine with ip address that do ping and are resolvable, any idea how to get round this problem (if possible) using Winsock 2.2?
Code:
WORD sockVersion;
WSADATA wsaData;
int nret;
LPHOSTENT hostEntry;
sockVersion = MAKEWORD(2, 2);
// Initialize Winsock as before
WSAStartup(sockVersion, &wsaData);
in_addr iaHost;
iaHost.s_addr = inet_addr("38.144.194.35"); //does not work Y_Y
//iaHost.s_addr = inet_addr("80.249.110.189"); //works
hostEntry = gethostbyaddr((const char *)&iaHost, sizeof(struct in_addr), AF_INET);
//hostEntry = gethostbyname("www.hal-pc.org");
if (!hostEntry) {
nret = WSAGetLastError();
Log( LOG_PRINT | LOG_THISSERVER, NULL, "(SID:%i) ERROR:",nret,"gethostbyname()");
cout << nret << endl;
// ReportError(nret, "gethostbyname()"); // Report the error as before
//hostEntry = gethostbyaddr("211.234.61.21", sizeof(struct in_addr), AF_INET);
// WSACleanup();
//return NETWORK_ERROR;
}
Regards
cyph
Last edited by cypher_soundz; March 26th, 2006 at 07:15 AM.
-
March 26th, 2006, 07:15 AM
#2
Re: Problem using Winsock 2.2 when host can't be resolved to a hostname
>>The problem I believe is that the host does not have a DNS entry (??), and therefore Winsock get confused and believes that the host is not up.
If the host is not up or does not have a valid DNS entry you cannot expect anything else but an error messages saying so.
Kurt
-
March 26th, 2006, 07:20 AM
#3
Re: Problem using Winsock 2.2 when host can't be resolved to a hostname
No the host is up, but there is no hostname linked to it,
it was speculation that "... therefore Winsock get confused and believes that the host is not up."
looking here seems that the same problem occurs ? http://www.codeguru.com/forum/showth...ht=error+11004
cyph
-
March 26th, 2006, 07:33 AM
#4
Re: Problem using Winsock 2.2 when host can't be resolved to a hostname
Allright Now I think that I understand what your saying.
You want to connect via the ip-address and you think that fails because the ip-address cannot be resolved to a hostname.
If that is so then you could temporarily add an entry to your hosts -file (located somewhere in yout systemdirectory/drivers/etc ) to find out if it is so.
Kurt
-
March 26th, 2006, 07:39 AM
#5
Re: Problem using Winsock 2.2 when host can't be resolved to a hostname
Great thanks, it worked!
Now is there any way around this? As i said in my edit above , im not up to speed with winsock
cyph
-
March 26th, 2006, 07:57 AM
#6
Re: Problem using Winsock 2.2 when host can't be resolved to a hostname
Originally Posted by cypher_soundz
Now is there any way around this? As i said in my edit above , im not up to speed with winsock
Sorry my knowledge about winsock is more or less non existant.
As far as I know it is as you are saying in your edit. Usually windows doesn't have any problems to connect if you don't provide a hostname ( ip is enough ). But I usually connect to hosts via the ip-address only if I know that there is no DNS-entry at all. So this could very well be a bug in the OS and not only in winsock.
Kurt
Last edited by ZuK; March 26th, 2006 at 08:23 AM.
-
March 30th, 2006, 02:30 PM
#7
Re: Problem using Winsock 2.2 when host can't be resolved to a hostname
As far as I know, target i.p does not need a dns to be able to connect to it.
I think the issue may be your use of "gethostbyaddress", if you are only wishing to connect to them, then supplying the i.p alone should be enough.
Dns would only really matter if it were pointing to a dynamic ip address (changes) so you could continue connecting to the dns without having to update.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|