1.需要包括头文件:#include <afxsock.h> 或者WinSock 否则gethostname无法用
2. gethostname 返回值是-1 ,这是因为没有调用WSAStartup
同时也可以调用 AfxSocketInit
不过,该函数同样是调用WSAStartup
1.需要包括头文件:#include <afxsock.h> 或者WinSock 否则gethostname无法用
2. gethostname 返回值是-1 ,这是因为没有调用WSAStartup
同时也可以调用 AfxSocketInit
不过,该函数同样是调用WSAStartup