0

当我运行这段代码时,它总是返回没有可用的开放端口。我该如何解决这个问题?

for(y=1; y<20000; y++ ) {
    sock = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
    Info.sin_addr.s_addr = inet_addr(IPaddress);
    Info.sin_family = AF_INET;
    Info.sin_port = htons(y);

    x = connect (sock, NULL, NULL);

    if(x != SOCKET_ERROR ){
        cout << "Port" << y <<  "- OPEN ! " << endl;
    }

    closesocket(sock);
}

WSACleanup();

cout << "Port scan has finished " << endl;
system("pause");
4

0 回答 0