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; }

In reply to Re: how to fork/spawn 64k telnet connections and keep them all open by DrHyde
in thread how to fork/spawn 64k telnet connections and keep them all open by ike_ipsec_dude

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.