avo has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I tried searching... but no luck. I am looking for a POE TCP tunnel that works in reverse... in other words I have a host which is behind firewall which I need to connect to me and allowing me to open a connection through that existing one to another port on the remote machine. For example - my local host awaits the remote to connect on port 3000, when the remote is connected using my local port 3001 I would like to be able to have TCP tunnel to port 2000 on the remote machine. Any thoughts ? All help will be appreciated!

Replies are listed 'Best First'.
Re: Two Way TCP Tunnel with POE
by rcaputo (Chaplain) on May 31, 2008 at 02:36 UTC
Re: Two Way TCP Tunnel with POE
by RMGir (Prior) on May 31, 2008 at 00:36 UTC
    POE just doesn't seem like the way to go here... Why not just do a straightforward proxy server?

    POE can do a lot of stuff, but it seems like overkill for this application - just open connections to both sides (or listen on one side, then connect on the other) then use select to sysread whenever there's data on one channel, and syswrite it to the other...

    You could get fancier than that, but I doubt you need to...

    PS: Or you could just use Net::Proxy :)


    Mike
Re: Two Way TCP Tunnel with POE
by salva (Canon) on May 31, 2008 at 10:45 UTC
    mfwd is an utility I wrote a long time ago that does exactly that. It is written in C and the code is available from the SourceForge CVS. I have not been maintaining it, but it is pretty simple, so any compile or runtime error should be easy to fix. At least, it still compiles cleanly on my Linux box.

    There were also a popular Perl script that implemented a TCP proxy, but I can remember its name :-(

    But anyway, my advise would be also to use something more standard like SSH tunnels if you can!