I am trying to write a process that essentially acts as an conduit between two other proceses. I want to open a serversocket A and a client socket B. Something like.
$server = IO::Socket::INET->new( Listen => 5, LocalAddr => 'localhost', LocalPort => $local_port, Proto => 'tcp') or die "Cant create server socket: !"; while ($client = $server->accept) { $proxy = IO::Socket::INET->new( PeerAddr => $proxy_host, PeerPort => $proxy_port, Proto => 'tcp') or die "cannot create proxy socket: $!" # At this point here I want to connect the $proxy file handle and # the $client file handle .. }
By connect I mean I want the any op from $client to be shoved into the ip of $proxy and any op from $proxy to be shoved in the ip of $client. Clear .. no not to me either I am sure I am doing summat wrong.

Now I guess I could do this by spawning 2 threads one to read and one to write then just bucket the data across however I am looking for a simpler solution.

I would be keen to hear anyones suggestions. I half think I am missing some thing and should not be even attempting this so please tell me I am being dumb if you see that to be the case.

Thanks very much for your time.
--

Zigster


In reply to Is there any way to connect two sockets together? by zigster

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.