Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Control number of running telnet sessions

by SteveB (Novice)
on Oct 17, 2007 at 09:34 UTC ( #645412=perlquestion: print w/ replies, xml ) Need Help??
SteveB has asked for the wisdom of the Perl Monks concerning the following question:

I'm writing a script whereby I will be contolling modem sessions via an Access server to dial out and collect information from remote boxes. As I have a number of modems available to me I want to control the number of sessions that I fire off to get this information. As I telnet to the access server what would be the best control structure to use in perl to do this?

Comment on Control number of running telnet sessions
Re: Control number of running telnet sessions
by jettero (Monsignor) on Oct 17, 2007 at 10:50 UTC

    To be honest, I don't really understand the question...

    But if there's lots of telnet-ing to be done from one processes.... POE::Component::Client::Telnet will probably help. POE does all the hard work for you. I've had a mixed relationship with POE. Sometimes I find it a little tricky, but when I'm connecting to lots of services from one process, it's really the way to go.

    -Paul

      Basically I have a list of devices that I need to connect to on a daily basis. Using an Access Server with 30 modems I want to manage and control the utilisation of the modems. So when I finish collecting data from a device I'll close down the session and then I want a 'session controller' to start another collection process to a different device. So I utilise the modems as much as possible at all times. The modems are accessed via a pool so I use a telnet and tcp port to initiate a modem connection. Hopefully that explains the background and what I'm trying to achieve better.
Re: Control number of running telnet sessions
by idsfa (Vicar) on Oct 17, 2007 at 15:08 UTC

    If all you need to do is limit the number of simultaneous but otherwise identical connections, Parallel::ForkManager should do the trick. You might have to add a little more logic if you need to use a different target port for each connection, but that's just a pop/push stack.

    my @portlist = qw/10001 10002 10003 10004/; use Parallel::ForkManager; $pm = Parallel::ForkManager->new(scalar @portlist); foreach my $target (@targets) { my $pid = $pm->start and next; my $port = pop @portlist; system("telnet $target $port"); push @portlist, $port; $pm->finish; # Terminates the child process }

    The intelligent reader will judge for himself. Without examining the facts fully and fairly, there is no way of knowing whether vox populi is really vox dei, or merely vox asinorum. — Cyrus H. Gordon

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://645412]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (13)
As of 2014-07-22 17:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (120 votes), past polls