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;
}