problem with gethostbyaddr
-
Hi, ive got this problem : when i use this everything is ok : LPHOSTENT hostent; hostent = gethostbyname("localhost"); but with this : LPHOSTENT hostent; CString strIP="127.0.0.1" hostent = gethostbyaddr (strIP,strIP.GetLength (),AF_INET); i cant connect to the server (of course it does the same with other adresses then localhost :) Can u tell me plz what im doing wrong ? And the third para in gethostbyadd. Does it have to be always AF_INET or there are some choices? Thx in Advance.
-
Hi, ive got this problem : when i use this everything is ok : LPHOSTENT hostent; hostent = gethostbyname("localhost"); but with this : LPHOSTENT hostent; CString strIP="127.0.0.1" hostent = gethostbyaddr (strIP,strIP.GetLength (),AF_INET); i cant connect to the server (of course it does the same with other adresses then localhost :) Can u tell me plz what im doing wrong ? And the third para in gethostbyadd. Does it have to be always AF_INET or there are some choices? Thx in Advance.
What does
WSAGetLastError()
return after the failed call togethostbyaddr()
? -- You're entertaining at least. -
Hi, ive got this problem : when i use this everything is ok : LPHOSTENT hostent; hostent = gethostbyname("localhost"); but with this : LPHOSTENT hostent; CString strIP="127.0.0.1" hostent = gethostbyaddr (strIP,strIP.GetLength (),AF_INET); i cant connect to the server (of course it does the same with other adresses then localhost :) Can u tell me plz what im doing wrong ? And the third para in gethostbyadd. Does it have to be always AF_INET or there are some choices? Thx in Advance.
unsigned long ulResult = inet_addr(strIP);
if (INADDR_NONE != ulResult)
{
hostent = gethostbyaddr((char *) &ulResult, sizeof(ulResult), AF_INET);
// now you can print hostent->h_name
}
A rich person is not the one who has the most, but the one that needs the least.
-
unsigned long ulResult = inet_addr(strIP);
if (INADDR_NONE != ulResult)
{
hostent = gethostbyaddr((char *) &ulResult, sizeof(ulResult), AF_INET);
// now you can print hostent->h_name
}
A rich person is not the one who has the most, but the one that needs the least.
Thanks :)