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

I am looking to write a load-balancing proxy system, and am running into a few problems. This system would accept a socket connection, read several lines from the socket, and send the data to one of 13 sockets, read the data recieved from that socket, and write it to the accepted socket. The problem I am having is the 13 connections require keep-alives every 10 minutes, and if it loses the login, it needs to re-login.


Example: client connects to proxy, proxy decides that it last sent data to server[11], proxy sends data to server[12], proxy notices that server[8] has not had data sent to it in 10 minutes +, proxy sends a keep-alive to server[8], proxy (finally) recieves data from server[12], proxy sends data from server[12] back to client, client closes connection.

After thinking long and hard about this, the only way I can think of to do this is with a whole bunch of forks, and I am thinking that their has to be a more elegant way. Please help. Tim

Replies are listed 'Best First'.
Re: keeping open stateful connections.
by Aristotle (Chancellor) on Jun 05, 2002 at 16:59 UTC
    You aren't overly explicit, but it sounds like IO::Select or maybe IO::Poll would be what you're after.

    Makeshifts last the longest.