in reply to Re^2: Help finding relevant modules to write a port forwarder from pool
in thread Help finding relevant modules to write a port forwarder from pool

Check out POE http://poe.perl.org. If it's your first foray, it will take a while to get used to it (Do a search on PM for poe tutorial and you will come up with a discussion). IMHO it would be a better investment to lean POE and do this using it rather than coding it at a low level. Plus POE is non-blocking.

AnyEvent is another alternative.

- Markov

Replies are listed 'Best First'.
Re^4: Help finding relevant modules to write a port forwarder from pool
by mje (Curate) on Oct 08, 2009 at 16:17 UTC

    Some of the other processes in this project already use POE and I am familiar with it. This process is just to mimic an expensive piece of hardware at this stage and as far as I can see it simply boils down to:

    @pool = (1..N); listen on port N loop { select(waiting for connect); accept pick port from pool fork child does connect, reads socket, writes to forwarder socket, reads results and writes back to client. closes sockets and exits. parent looks for dead children to add port back to pool }

    and POE seems a bit of an overkill for this. Guess I'll knock up the above first.

      If POE seems like overkill, take a look at IO::Lambda. It's a bit weird, but it should be able to make the thing you need without having to fork for each connection.

      -- Randal L. Schwartz, Perl hacker

      The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.