Bonjour, j’essaie de reproduire le programme tracert
de Windows en c++, j’ai un petit début mais en peu d’aide serait très appréciable
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | #include <iostream> #include <WS2tcpip.h> #pragma comment (lib, "ws2_32.lib") int main() { WSADATA wsdata; int iResult = WSAStartup(MAKEWORD(2, 2), &wsdata); if (iResult != 0) { std::cout << "Error at: Initializing Winsock.. " << std::endl; return 1; } else { std::cout << "Status : " << wsdata.szSystemStatus << std::endl; } struct sockaddr_in hints; const char* name = "172.217.13.99"; hints.sin_family = AF_INET; inet_pton(AF_INET, name, &hints.sin_addr); char ptrTo[NI_MAXHOST]; char port[NI_MAXHOST]; memset(ptrTo, 0, NI_MAXHOST); memset(port, 0, NI_MAXHOST); if (getnameinfo ((sockaddr*)&hints, sizeof(hints), ptrTo, NI_MAXHOST, port, NI_MAXHOST, 0) == -1) { std::cout << "Error.." << std::endl; WSACleanup(); } else { std::cout << "\nFrom: " << name << "\nTo: " << ptrTo << "\nPort: " << port << std::endl; printf("\n"); } return 0; } |
+0
-0