如何禁用套接字的 Nagle 算法?
我正在写一些Python,现在被困住了。 我认为这个“Nagle algoritm”是问题所在,因为我的包裹由于某种原因对客户延迟了一段时间。
我已经在客户端和服务器上尝试过此操作,但它似乎不起作用(或者有另一个问题导致它):
socketobj.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
有什么想法吗?
编辑:我的问题的完整解释可以在这里找到: http://www.gamedev.net /community/forums/topic.asp?topic_id=554172&whichpage=1�
I'm writing some python and are stuck at the moment.
I think this "Nagle algoritm" is the problem since my packages are delayed some time for some reason to the client.
I've tried this on both client and server but it doesn't seems to work (or there's another problem causing it):
socketobj.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
Any ideas?
EDIT: A full explanation of my problem can be found here:
http://www.gamedev.net/community/forums/topic.asp?topic_id=554172&whichpage=1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我对Python的套接字不熟悉,但是它有flush方法吗?即使 Nagle 被禁用,如果您不写入 X 个字节,大多数套接字实现也会缓冲。但是,如果您调用刷新,则应立即发送字节。
I'm not familiar with Python's sockets, but does it have a flush method? Even with Nagle's disabled, most socket implementations will buffer if you don't write X number of bytes. However, if you call flush, the bytes should be sent immediately.