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

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.

  • Comment on Re^4: Help finding relevant modules to write a port forwarder from pool
  • Download Code

Replies are listed 'Best First'.
Re^5: Help finding relevant modules to write a port forwarder from pool
by merlyn (Sage) on Oct 08, 2009 at 16:37 UTC
    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.