void mycode()
{
struct sockaddr_in saGNI;
char servInfo[NI_MAXSERV];
WSADATA wsadata;
if (WSAStartup(MAKEWORD(2, 2), &wsadata) != 0) {
//printf("WSAStartup failed: %d\n", statuswsadata);
}
saGNI.sin_family = AF_INET;
saGNI.sin_addr.s_addr = inet_addr("10.80.101.162");
saGNI.sin_port = htons(64);
char host[512]; // <-- information to obtain
getnameinfo((struct sockaddr *) &saGNI, sizeof(struct sockaddr), host, NI_MAXHOST, servInfo, NI_MAXSERV, NI_NUMERICSERV);
}
我想获得一个IP作为输入的主机名。上面的代码就是这样做的,但我更喜欢用Boost asio来做,有可能吗?