Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问下怎么知道是客户端关闭的链接还是服务端关闭的链接 #256

Closed
cxjhk opened this issue Oct 21, 2021 · 3 comments
Closed
Assignees
Labels
help wanted Extra attention is needed question Further information is requested
Milestone

Comments

@cxjhk
Copy link

cxjhk commented Oct 21, 2021

What is your question about gnet?
Please describe your question meticulously.

@cxjhk cxjhk added help wanted Extra attention is needed question Further information is requested labels Oct 21, 2021
@panjf2000
Copy link
Owner

服务端一般不会主动关闭socket(除非你自己关闭),只会在读写socket失败的时候关闭,调用 OnClosed 回调,所以一般可以认为是客户端关闭,或者socket出错了。

@cxjhk
Copy link
Author

cxjhk commented Oct 21, 2021

我们有业务场景需要知道是服务端关闭还是客户端自己关闭 用swoole的话会返回一个reactorId 我能知道是不是客户端断开的

@panjf2000
Copy link
Owner

panjf2000 commented Nov 1, 2021

除了你自己调用 c.Close() 之外,gnet server 不会主动关闭一个没有发生错误的 socket。

@panjf2000 panjf2000 added this to the Long term milestone Jan 3, 2022
0-haha pushed a commit to 0-haha/gnet that referenced this issue Jan 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants