Thanks! I reinvestigated the proper use of select and found I was using it wrong. My code now works without forking or pipes or anything other than Select!

use IO::Socket; use IO::Select; use IO::Handle; $A_lsn = new IO::SOCKET::INET (LocalHost => 'localhost', LocalPort => 1234, Type => SOCK_STREAM, Proto => "tcp", Reuse => 1, Listen => 5) or die "A Server socket couldn't be created: $@\n"; $B_lsn = new IO::SOCKET::INET (LocalHost => 'localhost', LocalPort => 5555, Type => SOCK_STREAM, Proto => "tcp", Reuse => 1, Listen => 5) or die "B Server socket couldn't be created: $@\n"; my $sockets = new IO::Select(); $sockets->add($A); $sockets->add($B); while(@ready = $sockets->can_read) { foreach $sockets (@ready) { if ($sockets == $A_lsn) { #new A client (sends data) $A_sock = $A_lsn->accept() $sockets->add($A_sock); } elsif($sockets == $B_lsn) {#new B client (recv data) $B_sock = $B_lsn->accept(); $sockets->add($B_sock); } elsif($sockets == $A_sock) #A client sent data, forward to all B clients $buf = <$A_sock> my @writers = $sockets->can_write; foreach $writer (@writers) { if ($writer == $A_sock) { #ignore } else { print $writer $buf; } } }

In reply to Re^2: Proxy Server Help by PhillyR
in thread Proxy Server Help by PhillyR

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.