I'm a little fuzzy on exactly what you're trying to accomplish, so let me ramble a little...perhaps some of it may be relevant.

Is the goal to have a single connection to the other server and multiple connections to clients, i.e. a multiplexer? If so, I would think that you wouldn't want to create a new Server object when you get a new connection from a client. Instead, you should add the new client connection into the select object. You seem to be set up this way since you have for $socket (@ready){, but from your description, my guess is that you added $extsock to the select object elsewhere.

If you want multiple Server objects, you will need to give them control so that they can run their loop, most likely by calling fork or by calling the method that contains the code you listed. In that case, you would likely want to change the while to an if so that you don't block.

All that aside, assuming that you insert all clients into the @clients array, your "unknown data" should be from $extsock. This is easy enough to check:

if ($socket == $extsock){ print "Got data from extsock\n"; } else { print "Got data from an unknown handle ($socket)\n"; }
I've been doing a *lot* of this kind of stuff lately, so if you can describe your goals in a little more detail, I can probably give you some code to help you out.

In reply to Re: select() on a client and server socket by bschmer
in thread select() on a client and server socket by amir

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.