in reply to Re: Re: Suggestions & Improvements
in thread Suggestions & Improvements on a portscanner using IO::Socket

As suggested, fork will do the trick. The thing you need to be careful of is not swarming the machine with forks. Up to a point, it will get the job done faster, but isn't very friendly to the other programs.

Also, at some point you probably get diminishing returns until you have so many forks that none of them get done in a reasonable amount of time.

So...keep a counter of how many forks you have launched and don't start new ones until some have been reaped. (see waitpid...). On my own scanner and on various stress testing clients, I have provided the number of forks to be defined at command line (or defaulted to 5 at a time). See nmap.

IO:Select is not what you want here. Not only is it not threading or forking, but is actually used to multiplex reading and writing to/from handles that have already been established. Once you get the scanner done, write a multiplexing server for some real fun and a good introduction to network server coding. :-)

Have a blast!