is it feasible to have a perl socket listener on one single tcp port that then redirects the socket feed after examining the ip address to another listener on the same box ?

It doesn't make much sense to do that at the level of a Perl script. Once the remote client connects, it won't, in the absence of some pre-existing protocol, reconnect to another listener. All you could do is have your server connect to the other local listeners and then act as go-between (proxy), forwarding each inbound packet and getting any responses and sending them back to the remote system.

It won't make any future connects (seperate or concurrent) from that remote system go directly to the other local listener. They'll still come through the original listener. Each having to connect to a new instance of the other local listener and relay through. You'd just be creating lots of middleman processes that do nothing but create a bottleneck.

Once a remote client connects to your listener, all you need is to hand off the accepted socket to the right piece of code--be that a process or thread--dependent upon the remote IP of the inbound connection. And that's very easy, far less costly, and far less fragile.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP an inspiration; A true Folk's Guy

In reply to Re: Socket Traffic Cop by BrowserUk
in thread Socket Traffic Cop by sans-clue

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.