ZLMediaKit / ZLToolKit

一个基于C++11的轻量级网络框架,基于线程池技术可以实现大并发网络IO
MIT License
1.94k stars 580 forks source link

Hello, can the socket add support for the reconnect mechanism? #66

Closed coding-lxm closed 3 years ago

coding-lxm commented 3 years ago

Blogger, the TCP socket used in the project often needs a reconnect mechanism. Can you add a configurable reconnect mechanism to the socket?

博主,项目中用到的tcp socket经常需要用到重连机制,能否在socket中添加个可配置的重连机制

TRANS_BY_GITHUB_AI_ASSISTANT

xia-chu commented 3 years ago

To support the various business and functionalities at the upper layer, the underlying API must be fine-grained. The reconnection scenario you mentioned is just one business case. Moreover, what kind of error triggers reconnection? What is the reconnection interval? How many times should it reconnect? These are all business-specific matters that should be implemented in the upper-layer code. Besides, I have already exposed the onErr (disconnect) event. How difficult is it to implement reconnection yourself? zlmediakit has many such reconnection scenarios, and it's not necessary to implement it in zltoolkit.

为了支持上层五花八门的业务和功能,底层api肯定是细粒度的,你说的重连场景只是一种业务而已,而且什么错误时重连?重连间隙是多少?重连多少次?这些都是很业务的事情,应该在上层代码去实现的。而且我都把onErr(断开)事件抛出来了,自己实现下重连多难呢? zlmediakit有很多重连这样的场景啊,并不一定要在zltoolkit实现啊

TRANS_BY_GITHUB_AI_ASSISTANT

coding-lxm commented 3 years ago

Okay, thanks for the reply.

好的 感谢回复

TRANS_BY_GITHUB_AI_ASSISTANT