Re: socketpair - problem communicating to multiple subprocesses



Thank you for your help.

Regards

Honza Mach

On Sun, 2011-06-05 at 13:09 -0400, Uri Guttman wrote:
"HM" == Honza Mach <jan.mach@xxxxxxxxx> writes:

HM> my ($child, $parent);

HM> foreach my $i (1..3)
HM> {
HM> socketpair($child, $parent, AF_UNIX, SOCK_STREAM, PF_UNSPEC)
HM> or die "socketpair: $!";

you are using the same variables to store each socketpair in the
loop. so that will close the previous sockets and open up new ones. you
need to keep them in a hash like you do with the pids (in the
parent). then you can communicate with a unique socket to each child. of
course in the child you can keep using these vars as they only need to
track the single socket to the parent.

and there are modules that do most of this for you. see if one of them
is right for you.

uri


Attachment: smime.p7s
Description: S/MIME cryptographic signature