Perl parent-child communication.

T

tower.grv

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?
 
A

anno4000

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
 
X

xhoster

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,954
Messages
2,570,116
Members
46,704
Latest member
BernadineF

Latest Threads

Top