I need to write a simple proxy + loadbalancer (NOT an http proxy) that will accept a connection and the first line of protocol, pick an actual server based on info in that first line plus data I have on server loads, and fork off a child that then channels everything from the client through itself to the selected server/port (and vice versa).
(The routing depends on data in the first line of protocol received from the client, so I can't just use a generic load-balancer; a large part of the point is hiding the splitting up of some overloaded servers from the client software.)
It looks like I can do this fairly easily using IO::Connect (all the pieces, how to set the backlog queue size, how to do non-blocking IO all seem pretty obvious).
Liking, in principle, using higher-level tools, I started looking at Net::TCP and sub-classes including Server. While I can create a server, accept a connection, and interact with that connection, I can't actually find how to do all the little adjustments to params, or how to do simple stuff like determining the IP address of the client that connected to me.
So, my question is -- for a really simple proxy like this, is there actually an advantage to me in using Net::TCP::Server, or is going straight to IO::Connect the right choice? And if I *should* be using n::t::s, is there perhaps a tutorial or HOWTO somewhere that would get me started better than just reading the man pages has?
In reply to Simple proxy: Net::Tcp::Server vs. IO::Connect by dd-b
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |