Perl parent-child communication.

Discussion in 'Perl Misc' started by tower.grv@gmail.com, Apr 24, 2007.

  1. Guest

    Hello.

    I am developing application that has UDP server.
    Application starts, create child thread (with fork), child thread call
    function to create UDP server
    #-------------------------------------------------------------------------
    $sr = IO::Socket::INET->new(
    Proto => "udp",
    LocalPort => $MYPORT
    );
    while ($sr->recv($TD, 128)) {
    #here it need to send data to main (parent) thread.
    }
    #------------------------------------------------------------------------

    I tried to use signals (%SIG and kill).
    But width signals I can only call some function from parent process
    and I can't send received data.
    How can I do this?
    What another ways methods be used to send data to parent process?
     
    , Apr 24, 2007
    #1
    1. Advertising

  2. -berlin.de Guest

    <> wrote in comp.lang.perl.misc:
    > Hello.
    >
    > I am developing application that has UDP server.
    > Application starts, create child thread (with fork), child thread call
    > function to create UDP server
    > #-------------------------------------------------------------------------
    > $sr = IO::Socket::INET->new(
    > Proto => "udp",
    > LocalPort => $MYPORT
    > );
    > while ($sr->recv($TD, 128)) {
    > #here it need to send data to main (parent) thread.
    > }
    > #------------------------------------------------------------------------
    >
    > I tried to use signals (%SIG and kill).
    > But width signals I can only call some function from parent process
    > and I can't send received data.
    > How can I do this?
    > What another ways methods be used to send data to parent process?


    See prldoc perlipc.

    Anno
     
    -berlin.de, Apr 24, 2007
    #2
    1. Advertising

  3. Guest

    "" <> wrote:
    > Hello.
    >
    > I am developing application that has UDP server.
    > Application starts, create child thread (with fork), child thread call
    > function to create UDP server
    > #------------------------------------------------------------------------
    > - $sr = IO::Socket::INET->new(
    > Proto => "udp",
    > LocalPort => $MYPORT
    > );
    > while ($sr->recv($TD, 128)) {
    > #here it need to send data to main (parent) thread.
    > }
    > #------------------------------------------------------------------------


    Why does the child need to send data to the main thread? If the main
    thread needs the data, why doesn't the main thread just dispense with the
    child altogether and set up the UDP server itself and read the data itself?

    >
    > I tried to use signals (%SIG and kill).
    > But width signals I can only call some function from parent process
    > and I can't send received data.
    > How can I do this?


    With some kind of socket or pipe between the child and parent, if the child
    is needed in the first place. What you have given us is a not a problem,
    but rather a failed attempt at a solution. We can't tell you what the
    successful solution will be unless you tell us what the actual problem you
    are trying to solve is.

    > What another ways methods be used to send data to parent process?


    Other than pipes and sockets, there is shared memory. And I guess you
    could use temp files.

    Xho

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
     
    , Apr 24, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. SJ
    Replies:
    4
    Views:
    1,308
  2. Noel Dolan
    Replies:
    0
    Views:
    261
    Noel Dolan
    Jul 18, 2004
  3. orion30
    Replies:
    2
    Views:
    106
  4. SJ
    Replies:
    3
    Views:
    135
  5. Bitswapper
    Replies:
    5
    Views:
    174
    Prasad, Ramit
    Aug 27, 2013
Loading...

Share This Page