Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

How to share Class object of one process to other external process?

by srlbharu (Acolyte)
on Mar 05, 2013 at 06:10 UTC ( #1021757=perlquestion: print w/ replies, xml ) Need Help??
srlbharu has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I have created Telnet object in one class's new function. Using this telnet object I am sending and receiving commands and respective responses.

But the design should be like this: I need to send the command in the current process using the telnet object but, receiving the response should be in the other process with the same telnet object.

           +----------+              +----------+
           | Client   |   Telnet     |  Server  |
           |          |              |          |
           |  +----+  | Send cmds    |          | 
           |  |Proc|--|------------->|          |
           |  |ess1|<-|--------------|          |
           |  +----+  |  Rx Res      |          | 
           |          |              |          |
           |          |         +----|          |
           |  +----+  |         |    +----------+
           |  |Proc|  |         |
           |  |ess2|<-|---------+
           |  +----+  |   Rx Res
           |          |
           +----------+ 

To achieve this, I tried to use below methods to spawn a process.

fork() system()

I created the external process using Win32::Process but from the main process, how can I get the telnet object to receive the responses.

From the diagram, I am sending commands and waiting for the response. Once the response comes then I move to the next command to send.

For some commands, response will be coming only after the next command is passed.

To pass the next command, I should come out from the wait loop.

Hence I am trying to create a child process for the wait loop.

Perl version: 5.6 OS: Windows

Comment on How to share Class object of one process to other external process?
Download Code
Re: How to share Class object of one process to other external process?
by kielstirling (Scribe) on Mar 05, 2013 at 09:17 UTC
    Sounds like a IO::Pipe would work for this problem. Does Windoz have pipes? If it does then that should sort you out.
    ...
    see later reply

      Hi, IO::Pipe is available in windows with current perl version installed. But I do not know how to use it to resolve. Can you please let me know the design such that the same telnet object can be used in two processes? Thanks in advance....

        Is the server a process that you have created ?? if yes why not open a socket. This way you will not need telnet. perldoc sockets
Re: How to share Class object of one process to other external process?
by BrowserUk (Pope) on Mar 05, 2013 at 15:16 UTC
    I need to send the command in the current process using the telnet object but, receiving the response should be in the other process with the same telnet object.

    Why?

    Ps. Do you notice anything strange about your posts compared to everyone elses? You won't get further responses from me unless you start respecting local conventions.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      Sorry, I didnot understand.. :-( Any wrong convention with my post????

        Every time you create a post here, you get a reminder to
        Use:  <p> text here (a paragraph) </p>
        and:  <code> code here </code>
        to format your post; it's "PerlMonks-approved HTML"

        See also "Tags You Should Not Use" in Markup in the Monastery

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2014-12-20 03:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (95 votes), past polls