当我运行此代码时,它始终返回没有可用的开放端口。我该如何解决这个问题?
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");