PPP适配器是啥
运行下面书上的代码,输出了两个地址。然后我在CMD里运行 ipconfig /all,分别找到了这两个地址的位置,一个在NIC部分,一个在PPP适配器部分。我查了,NIC是网卡的意思,PPP适配器是什么,怎么也有地址。PPP适配器在本机上还是在电脑外面。
#include <afxwin.h>#include<iostream>using namespace std;#include<afxtempl.h>#include<locale.h>#include <winsock2.h>class CInitSock{public: CInitSock(BYTE minorVer = 2, BYTE majorVer = 2) { WSADATA wsaData; WORD sockVersion = MAKEWORD(minorVer, majorVer); if( ::WSAStartup( sockVersion, &wsaData) != 0) { exit(0); } } ~CInitSock() { ::WSACleanup(); }};CInitSock initSock;void main(){ setlocale(LC_ALL,"chs"); char szHost[256]; ::gethostname(szHost,256); hostent * pHost = ::gethostbyname(szHost); in_addr addr; for(int i = 0;; i++) { char * p = pHost->h_addr_list[i]; if(p == NULL) break; memcpy(&addr.S_un.S_addr, p, pHost->h_length); char * szIp = ::inet_ntoa( addr ); printf(" 本机 IP 地址: %s \n", szIp); }}