Delphi7 Indy fast portscan timeout problem

Posted on 2006-05-22
Medium Priority
Last Modified: 2010-04-05
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!
Question by:gutyka
  • 3
LVL 17

Expert Comment

ID: 16739563
I've tried your code, and I do not get the lock up (windows 2000, 256meg ram)
I have 6 valid pcs in the first 10 ip addresses, and it happily queries them but finds no open port, it then continues and I don't get a lock up
could it be a resource issue?
i.e. does a reboot sort it out?
Do you have a firewall that could be interferring?

Author Comment

ID: 16742170
It turned out to be a WinXP SP2 issue :( On a machine with Windows XP SP1 it works perfectly, after installing Service Pack 2 the problem occurs immediately (no virus scanner, disabled internal firewall, no third-party firewall). Installing Indy 10 won't solve the problem either. So I increase the points because it seems to be a harder problem.

Author Comment

ID: 16745965
I've tried it with TClientSocket and TTCPClient with similar results. I have used non-blocking connections and first a timer for delaying then the OnConnect and OnError events to figure out whether it connects or not. It didn't lock up but after giving back the first results it won't produce any connection. If I wait for about a minute it will run with the same results, so the origin of the problem seems to be identical with the Indy components'. I emphasize that it only happens on WinXP SP2, on SP1 (and for ex. on Win2000) it works fine. I use Delphi 7.

HEEEELP! :( (now it is for 300 points...)

Accepted Solution

piba earned 1200 total points
ID: 16746282
You have to hack the TCPIP.SYS file of windows XP-sp2.. it contains a hardcoded restriction of 10 pending connections i believe..

You can find a tool that should do the trick on http://www.lvllord.de/

Author Comment

ID: 16746914
It won't work to ask the players to hack their Windows so the solution is to do the "scanning" part in UDP. Thank you for your help!

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month15 days, 14 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question