ZLMediaKit / ZLToolKit

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

Unable to get peer_port, peer_ip #167

Closed swq123459 closed 1 year ago

swq123459 commented 1 year ago

dd1d308bd01a3aab038a87b938013be39134e1c1 Starting from this commit (including this commit), peer_port and peer_ip cannot be obtained. This was discovered while using zlmediakit and later traced back to this branch.

dd1d308bd01a3aab038a87b938013be39134e1c1从这个commit开始(包括该commit), peer_port和peer_ip, 无法获取,这是在使用zlmediakit发现的,后来追踪到这个分支

TRANS_BY_GITHUB_AI_ASSISTANT

xia-chu commented 1 year ago

UDP or TCP socket?

udp还是tcp socket?

TRANS_BY_GITHUB_AI_ASSISTANT

xia-chu commented 1 year ago

tcp didn't find this problem:

图片

tcp并没发现这个问题:

图片

TRANS_BY_GITHUB_AI_ASSISTANT

swq123459 commented 1 year ago

tcp

xia-chu commented 1 year ago

Previously, after calling the interfaces related to peer_port and peer_ip, the data would be cached. Now, this logic is removed.

Because the closeSocket operation is placed after onError.

之前调用peer_port和peer_ip相关接口后 会把数据缓存下来 现在去掉这个逻辑。 因为先closeSocket操作放在onError之后了

TRANS_BY_GITHUB_AI_ASSISTANT

swq123459 commented 1 year ago

Is that the expected behavior?

那就是预期行为吗

TRANS_BY_GITHUB_AI_ASSISTANT

xia-chu commented 1 year ago

那就是预期行为吗

No, you can get the peer IP address when triggering onError and the Session destructor. As long as the socket fd is valid, you can get it.

那就是预期行为吗

不是啊 触发onError以及Seession的析构函数时 都是可以获取到对端ip信息的 只要socket fd有效 都能获取到

TRANS_BY_GITHUB_AI_ASSISTANT

swq123459 commented 1 year ago

I can reproduce this here. Based on your description, I'll see if I can describe it more clearly.

我这里可以必现,根据你的描述,我看能不能描述更清楚一些

TRANS_BY_GITHUB_AI_ASSISTANT

xia-chu commented 1 year ago

This is caused by receiving a TCP reset, which results in EOF not having this problem. This bug has been fixed. Please check the latest code.

这个是收到tcp reset时导致的 eof没这个问题,这个bug已经修复了 请查看最新代码

TRANS_BY_GITHUB_AI_ASSISTANT

xia-chu commented 1 year ago

Thanks for the feedback!

感谢反馈!

TRANS_BY_GITHUB_AI_ASSISTANT