TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

High Performance TCP Proxy Server

75 pointsby ArashPartowabout 8 years ago

9 comments

huhtenbergabout 8 years ago
Very nice, but this is more of a demo code for boost::asio than something that is production-worthy.<p>For example, it doesn&#x27;t relay FINs between connections, doesn&#x27;t disable Nagle algorithm on the upstream socket, doesn&#x27;t wait for pending writes to complete before tearing down the connection, doesn&#x27;t handle congestion at all (potentially leading to unbound memory use), etc.
评论 #14174486 未加载
adontzabout 8 years ago
Why not just?<p>Linux: iptables -t nat -A PREROUTING -p tcp -s 192.168.20.200&#x2F;0 -d 192.168.0.100&#x2F;0 --dport 8080 -j REDIRECT --to-ports 20000<p>Windows: netsh interface portproxy add v4tov4 listenaddress=192.168.20.200 listenport=8080 connectaddress=192.168.0.100 connectport=20000 protocol=tcp
评论 #14175441 未加载
评论 #14174356 未加载
评论 #14175303 未加载
评论 #14174397 未加载
评论 #14174200 未加载
评论 #14174816 未加载
userbinatorabout 8 years ago
As someone who has also written a TCP proxy (along with <i>many</i> others...), after thoroughly reading the page I&#x27;m still unsure of how exactly this is &quot;high performance&quot;. 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&#x27;t. I found the explanation overly complex.<p>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.
评论 #14173759 未加载
评论 #14173547 未加载
matthewaveryusaabout 8 years ago
As a sidenote if you don&#x27;t have a requirement to compile with C++03 I would recommend using the standalone asio library free from boost[1]. The only things you need to modify are the includes and namespaces.<p>[1] <a href="http:&#x2F;&#x2F;think-async.com&#x2F;Asio&#x2F;Download" rel="nofollow">http:&#x2F;&#x2F;think-async.com&#x2F;Asio&#x2F;Download</a>
评论 #14173350 未加载
larvaetronabout 8 years ago
A similar application that I&#x27;m fond of is Pen, which also does simple load balancing and has udp support:<p><a href="http:&#x2F;&#x2F;siag.nu&#x2F;pen&#x2F;" rel="nofollow">http:&#x2F;&#x2F;siag.nu&#x2F;pen&#x2F;</a>
mdekkersabout 8 years ago
Ironically, the site appears down (I am redirected to google)
评论 #14174015 未加载
评论 #14173709 未加载
评论 #14174176 未加载
throwaway2016aabout 8 years ago
How does this compare to using HAProxy in TCP mode?
评论 #14173170 未加载
signa11about 8 years ago
are there benchmarks also available ? may you please share them for objective comparison with other implementations. thank you!
brudgersabout 8 years ago
If it meets the guidelines, this might make a good &#x27;Show HN&#x27;. Show HN guidelines: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;showhn.html" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;showhn.html</a>
评论 #14173888 未加载
评论 #14173981 未加载