#define _WINSOCK_DEPRECATED_NO_WARNINGS
#include "WinSock2.h"
#include "iostream"
#pragma comment(lib,"ws2_32.lib") //鏈接WinSock導入庫
using namespace std;
int main(int argc, char **argv) {
WSADATA wsaData;
WORD wVersionRequested = MAKEWORD(2, 2); //調用2.2版本
if (WSAStartup(wVersionRequested, &wsaData) != 0) { //加載WinSock動態鏈接庫
cout << "加載WinSock DLL失敗!\n";
return 0;
}
struct protoent *pProto;
for (int i = 1; i <= 256; i++) {
if ((pProto = getprotobynumber(i)) != NULL) { //協議查詢
cout << "協議名:" << pProto->p_name << endl;
cout << "協議號:" << pProto->p_proto << endl;
}
}
WSACleanup();
return 0;
}