"I say this makes since because when the first connection comes in the second, third and foruth do not exist yet so the forked process has no way of knowing abou them, Same with the second, third, fourth and so-on. How can I logically setup this code to keep an updated list of socket conenction on all forked children? "

It gets pretty hard to do this in a forking server model. I use the Net::EasyTCP module for this, but it dosn't use a forked model. The basic idea is to save your client objects in a hash, like this PSEUDOCODE:

my $new; my $counter = 0; my %clients; if($obj == $sock) { # Create a new socket $new = $sock->accept; $sel->add($new); $counter++ $clients{$counter}{'obj'} = $obj; $clients{$counter}{'ip'} = $obj->remoteip; #or whatever identifiers you can get

Now you have to figure out how to get that hash data to all your forked processes. You can either you pipes or sockets for the interprocess communication. It's more complicated than I can code of the top of my head.

The other option is to use a threaded server model, which has been done nicely at this node: Re: Re: ChatServer

In threads, you can use the cond_broadcast to communicate between threads.


I'm not really a human, but I play one on earth. flash japh

In reply to Re^2: Two-Part Socket Question. by zentara
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.