18,356
社区成员
发帖
与我相关
我的任务
分享
struct sockaddr_in ServerHostAddr;//服务主机地
ServerHostAddr.sin_family=AF_INET;
ServerHostAddr.sin_port=::htons(u_short(lPort));
ServerHostAddr.sin_addr.s_addr=::inet_addr(strIP);
PHOSTENT pResult;
{
pResult = gethostbyname(strIP); //ip
//if it is not success, try again by IP address.
if (pResult == NULL)
{
pResult = gethostbyaddr((const char *) &(ServerHostAddr.sin_addr.s_addr), 4, AF_INET); //域名
}
}