2 ms·
As someone who has also written a TCP proxy (along with many others...), after thoroughly reading the page I'm still unsure of how exactly this is "high perform
by userbinator 10y ago
As someone who has also written a TCP proxy (along with many others...), after thoroughly reading the page I'm still unsure of how exactly this is "high performance". It is also curious that, despite the fact that it uses a separate library for networking, the source is already quite a bit longer than some other proxies which don't. I found the explanation overly complex.
Around half the code in this implementation could probably be removed by the realisation that, after a connection is established, both ends are completely symmetric: all it needs to do is try to read from A and write to B, then try to read from B and write to A. If A closes, close B. If B closes, close A.
- zzzcpan 10y ago> If A closes, close B. If B closes, close A. It's shutdown() writes on EOFs, not close, with refcounting to also do close() when EOFs were detected on both directions (I also have written a TCP proxy). But yeah, TCP proxies are trivial, would be more interesting to see something like a tunneling proxy that sends data over multiple connections to maximize performance.
- tlarkworthy 10y agoHey, I am looking for a way of packing multiple TCP streams over a single TCP connection to a backend server. I can unpack them in application logic if necessary. Do you know what that is called? Kinda like SCTP
- RickHull 10y agoMultiplexing?
- tyingq 10y agoThe quick and dirty approach would be an ssh tunnel or vpn. There's also GRE tunnels which would be faster, but not encrypted. Any of these would work without having to change the application. Probably, though, it's best to start with why you would want to do that. You could be, for example, trying to solve something where a pub/sub model would work better. Or just two separate apps, on different ports. What's driving the idea of multiplexing?
- tlarkworthy 10y agoOh that's interesting, can we speak via email:- tom dot larkworthy at Google's popular email provider?
- apankrat 10y agoIt is symmetrical, but there are nuances. If A closes or errors out, the proxy should first push out any pending data and only then close B. The same goes for when A sends a FIN - it should flush any data queued at application level before calling shutdown() on B's socket. If A becomes unwritable, it should stop reading from B.