Delphi7 Indy fast portscan timeout problem
Posted on 2006-05-22
I need to write a network scanner which scans a whole subnet to find computers with a specified open port. This is for a multiplayer LAN game, to find the running servers. The scan should be fast with a low timeout. Surprisingly it won't work with the timeout less than 1000ms, which is too high for this task. If I set 10ms for the timeout it scans the first 11 IP addresses then locks up for several seconds then continues for another 11 IP addresses and so on. The extract of the code:
for i:=1 to 255 do begin
try TCPClient.Connect(10) except on E : Exception do end;
if TCPClient.Connected then TCPClient.Disconnect;
The problem can be that the scanned IP addresses are not "alive", but if the timeout is 1000ms no problem occurs.
Thank you in advance!