如何拒绝传入连接?
我有一个 TCPSocket,在某些情况下(例如,当我达到系统限制时)我想拒绝新连接。
如果我只是不“接受”连接,它仍然在队列中......
I have a TCPSocket and in some cases (for example, when I get to the system limit) I want to reject new connections.
If i simply do not "accept" the connection it still in the queue...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
真的在排队吗?它不会超时并刷新吗?
您可能希望保留一个额外的 buff 来接受连接,然后立即关闭该连接,在其他线程中执行此类工作,这样它就不会影响您的工作。不确定这是否有帮助..
Is it really in the queue ? doesn't it gets time-out and flushed ?
You might want to keep an extra buff for accepting connection and then immediately closes that, do this kind of work in other thread, so it does not affect your work. Not sure may this helps..
通过向“监听”呼叫提供号码来限制监听队列。恕我直言,之后无法更改它,因此您可能需要关闭然后重新打开套接字。
Limit the listening queue by providing a number to the "listen" call. IMHO it's not possible to change it afterwards, so you might need to close and then reopen the socket.