更新时间:2023-08-03 04:33:08
大家好,我是小环,我来为大家解答以上问题。socket编程原理,socket编程很多人还不知道,现在让我们一起来看看吧!
1、#include
2、请检查版本号是否为1.1 " << endl; exit(1); } iportFrom=atoi (argv[2]); iportTo=atoi (argv[3]); for (int i=iportFrom; i <= iportTo; i++) { cout << "正在建立socket................................" << endl; if ((testsocket=socket (AF_INET,SOCK_STREAM,0) ) == INVALID_SOCKET) { cout << "Socket建立失败!" << endl; exit(0); } target_addr.sin_family = AF_INET; target_addr.sin_port = htons(i); target_addr.sin_addr.s_addr = inet_addr (argv[1]); cout << "正在扫描端口:" << i << endl; if (connect (testsocket, (struct sockaddr *) &target_addr, sizeof(struct sockaddr)) == SOCKET_ERROR) cout << "端口" << i << "关闭!" << endl; else { iopenedport++; cout << "端口" << i << "开放 " << endl; } } cout << "目标主机" << argv[1] << "从" << iportFrom << "--" << iportTo << "共有" << iopenedport << "个端口开放" << endl; closesocket (testsocket); WSACleanup(); } return 0; } vc6.0 下 编译
本文到此讲解完毕了,希望对大家有帮助。