Hello, I am making a PHP frontend for a backend server using a custom protocol over TCP. Due to a fairly complex handshake when establishing connections to the backend server, I would like to persist the TCP connections to the backend server. Naturally, given the inherently stateless nature of HTTP (and especially so when using mod_php under Apache), I cannot do this directly in PHP.
I was thinking of having a local "proxy server", maintaining a pool of connections to the backend server. It is important that each user of the PHP frontend maintains his/her own connection to the backend server. Now, this is not a very complex program, but due to the many pitfalls of network programming, I would rather use a robust, mature application that could do things like this.
I am thinking something along the line of the PHP application connecting to the proxy server, states "I have an ID; 123", and from then on all content to/from the server is piped directly between the PHP frontend and the backend server.
Any suggestions on elegant solutions for this?
Thanks!