I'm not sure what you are asking, and you show no code, but I think you should google for "perl select client" and look at the examples. I would think from your description, is that you want a client to connect to multiple servers, and read write to them? The problem it seems to me, is when a message comes in, how would you know which of multiple servers to write to? You will have to keep a hash of the sockets and see who is sending, then reply to that socket. Usually a client is forked to make it bi-directional, see UDP bidirectional client

Things get complicated fast, if you want a bidirectional client that connects to multiple servers simultaneously. See Simple bi-directional forking commandline client for a single connect client. You could do probably it with select, but it will involve a complex while loop check like this:

# very crude pseudocode my $select = IO::Select->new($server1); $select->add($server2); $select->add(/*STDIN); #for sending # etc etc my @ready; while(@ready = $select->can_read) { my $socket; for $socket (@ready) { # see if you can read a socket ..... ..... } #see if $select handle is STDIN, if so, send it to all in @ready } # do socket close error checking here
The complexity will get so great, that you are better off using an eventloop system to watch your sockets, like POE or Tk or Gtk2. POE may have something already in it's cookbook, google for it. Look at the Tk client in Simple threaded chat server , it uses fileevent (similar to select) and it would be easy to extend to multiple server connections.

I'm not really a human, but I play one on earth Remember How Lucky You Are

In reply to Re: How to Multiplex a Client using IO::Select by zentara
in thread How to Multiplex a Client using IO::Select by muthuma

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.