u_long getaddressbyname(char* name)
{
WSADATA wsaData;
hostent* remoteHost;
if (WSAStartup(MAKEWORD(2, 2), &wsaData))
{
return -1;
}
remoteHost = gethostbyname(name);
if (remoteHost == NULL)
{
int dwError = WSAGetLastError();
if (dwError != 0)
{
switch (dwError)
{
case WSAHOST_NOT_FOUND:
//_log->warn("Host not found\n");
return -2;
case WSANO_DATA:
//_log->warn("No data record found\n");
return -3;
}
}
return -5;
}
else
{
return *(u_long *)remoteHost->h_addr_list[0];
}
}