57. TCP relay功能描述及Python实现

处理client与server的带宽不匹配

代码:https://github.com/chenshuo/recipes/blob/master/python/tcprelay2.py

这个版本没有正确处理关闭连接,没有做错误处理

目标server接收数据慢,则sendall会阻塞,自然从source读会变慢。不会造成数据堆积。用阻塞io自然解决带宽不匹配的问题

如果source关闭,在从source读数据,产生connection reset by peer

destination关闭,在向destination写数据,产生Broken pipe

发布了434 篇原创文章 · 获赞 171 · 访问量 8万+

猜你喜欢

转载自blog.csdn.net/INGNIGHT/article/details/102863643
今日推荐