portscanner, works slow in windows
Posted on 2003-11-26
i had made a small utility sometime back that did a portscan on a given ip. i was using it in linux, and it worked fine .. i.e, it was fast enough. the basic thing that i was doing was a connect, and then checking the return code to determine whether the port was open or not. scanning all ports from 1 to 65536 took abt 10 seconds
i then tried using the same code, with minor changes, e.g, had to add WSAStartup(), .. etc, to make it work on windows so that i could integrate it into another program. the problem is, it works really slow on windows ... scanning ports 22 to 30 (i.e, only 9 ports) takes over 5 seconds ..
anyone know what culd be the problem ??
struct sockaddr_in thePC;
///Getting the IPAddress from the IPAddress control
IPAddress = ntohl(IPAddress);
unsigned int theP;
SOCKET SockFDS = socket(AF_INET,SOCK_STREAM,0);
int n = connect(SockFDS,(sockaddr*)&thePC,sizeof(thePC));