Re: socketpair - problem communicating to multiple subprocesses

Thank you for your help.


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.


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

Relevant Pages

  • Re: When [exit] wont exit
    ... the child now does not talk to the parent at all. ... I thought maybe you meant for the parent to pass the child the socket over the pipe or some such. ...
  • socketpair - problem communicating to multiple subprocesses
    ... I am currently working on a project and I need parent process to fork ... my ($child, $parent); ... foreach my $kid ... I create socket pair in ...
  • Re: advices on sockets
    ... child processes are not dependent on the parent. ... connections, and other threads process existing connections. ... if I don't make the socket non-blocking the loop hangs on select. ...
  • Re: asking help for a peer-to-peer socket programming question
    ... Amy ... >> let elder child processknow and talk to these younger child ... > each child and the parent, and each child can send messages to the parent ... clients' information (socket discriptor)in order to broadcast messages ...
  • Forking a daemonic Socket listener from a CGI script - browser times out
    ... Socket server - which listens for a connection request from a socket ... However, I combine them into one CGI program, which forks a child process to ... process from the "CGI program" (parent) process, ...