in reply to Making a multi-threaded port scanner in perl?

A good start to help us help you better would be to show us the code that you tried but which did not work for you.

The general approach I would use would be to use a worker model like the following:

  1. Create a Thread::Queue, "$hosts". This is where the worker threads will get their units of work from.
  2. Read all the hosts into that queue, so the worker threads have something to do.
  3. Create another Thread::Queue, "$portstatus". This is where the worker threads will store their results.
  4. Create some worker threads, which will do mostly what your single-threaded version did:
    sub scan_host { while( my( $ip )= $hosts->dequeue() ) { warn "Scanning '$ip'"; ... do real work $portstatus->enqueue({ host => $ip, status => 'too lazy', }); }; } for( 1..$NUM_THREADS ) { threads->create( \&scan_host ); };
  5. Now, just read out the results as they come in:
    $hosts->end; while(my $result= $portstatus->dequeue()) { print Dumper $result; };

An easier way would be to run the nmap binary and use Nmap::Parser for the results.