There's not a straightforward way to do that. File descriptors are shared between parent and child, but not between siblings, so even if two sibling processes knew the file descriptor number they wouldn't be able to write to it.

The way that's closest to what you want is probably the most complicated way. If each parent and child maintain a socket between them, the parent can send new file descriptors to all children with ioctl.

A more straightforward way to handle it would be to have the parent process act as a central point for distributing information; it receives messages from each client over a pipe/socket, then writes them out to all of the other clients.

Another possibility is to write messages that should be sent into a shared memory segment, created with mmap or shmget.

Yet another possibility is to create threads instead of processes, since all threads in a process share file descriptors (though you should probably use locking to make sure writes to file descriptors don't get intermingled).


In reply to Re^2: Two-Part Socket Question. by sgifford
in thread Two-Part Socket Question. by Elijah

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.