in reply to how to fork/spawn 64k telnet connections and keep them all open

If you want to open 65536 connections in parallel, you're going to have problems because you'll run out of local sockets. But let's ignore that. Let's also ignore the minor detail that the range 192.168.0.0 - 192.168.255.255 is *not* a class B network :-) oops I didn't ignore it! It's a series of 255 class C networks.

Creating a bunch of variables like $t1, $t2, $t3 and so on for each connection would be a bad idea, as perl already has data structures available for storing lists of data like this, which are much easier to use. You could either store them in an array like so:

$t = Net::Telnet->new(...); $t->open(...); push @array, $t;
Or you could store them in a hash with the target IP addresses as the keys:
$hash{"$ip.$ip3.$ip4"} = $t
You are also *not* iterating over all of the addresses you want to. The range you say you want to work through runs from FOO.BAR.0.0 to FOO.BAR.255.255. You ignore a whole bunch of them. I'm not going to pick over your convoluted method for generating the list to figure out exactly what you skip over, but here's how I'd do it:
my $base = (192 << 24) + (168 << 16); foreach my $ip ($base .. $base+65535) { $t = Net::Telnet ... $t->open(... $hash{$ip} = $t; }

Replies are listed 'Best First'.
Re: Re: how to fork/spawn 64k telnet connections and keep them all open
by ike_ipsec_dude (Initiate) on Oct 02, 2003 at 13:07 UTC
    Thanks for the advice / inspiration :)

    As for it being useful it will be tremendously for IKE testing.