Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: How to approach this i by Perl?

by suaveant (Parson)
on Jan 04, 2010 at 20:59 UTC ( [id://815645]=note: print w/replies, xml ) Need Help??


in reply to How to approach this i by Perl?

I tend to use a socketpair for things like this...

http://perldoc.perl.org/functions/socketpair.html

                - Ant
                - Some of my best work - (1 2 3)

Replies are listed 'Best First'.
Re^2: How to approach this i by Perl?
by shabbu (Initiate) on Jan 05, 2010 at 11:39 UTC
    I am not quite sure how I can use socketpair to resolve my issue.

    I think I will try to get the threaded program working. I will need some help. Here is relevant sections of the code

    use vars qw(%conn $ssh); share(%conn); share($ssh); #code run by thread #Here is where I get the error #Invalid value for shared scalar at $ssh = function(); # in the function sub function { # Create a new pseudo terminal $pty = new IO::Pty $ssh = new Net::Telnet (-fhopen => $pty) return $ssh } # in the Telnet module the code looks like this sub new { my ($class) = @_; $self = $class->SUPER::new; *$self->{net_telnet} = { bin_mode => 0, blksize => &_optimal_blksize(), . . . } $self }

    Any idea how I can go about sharing $ssh object created by thread? Is it worth pursuing to use thread to solve this?

    Thanks Ashok

      You said you create forks, I assume you have a central script that these forks are created from. Create a socket pair for each fork and pass data back and forth over them. You can use something like IO::Select to see what has data waiting. Another option would be to maintain a file or directory with proper locking, or use regular sockets. There are many ways to go about it. Even signals could probably work for minor notification stuff.

                      - Ant
                      - Some of my best work - (1 2 3)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://815645]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-19 02:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found