如何在 iPhone 上的 TCP 连接上禁用 Nagle 算法
我正在构建一个套接字,使用
CFStreamCreatePairWithSocketToHost(kCFAllocatorDefault,
(CFStringRef) yourHostAsNSString,
yourPortAsInteger,
&myReadStream,
&myWriteStream);
and I see that when I send a messages with "myWriteStream" it concatenate few message together and then send them. I think it happens because of the Nagle algorithm and I want to disable it. Does any one knows how to do it?I'm building a socket , using
CFStreamCreatePairWithSocketToHost(kCFAllocatorDefault,
(CFStringRef) yourHostAsNSString,
yourPortAsInteger,
&myReadStream,
&myWriteStream);
and I see that when I send a messages with "myWriteStream" it concatenate few message together and then send them.
I think it happens because of the Nagle algorithm and I want to disable it.
Does any one knows how to do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不保证这会解决您的问题,但如果您想禁用 Nagle 算法,您需要从流中获取本机套接字并调用
setsockopt
。(向 Mike Ash 大声喊出复合文字< /a> 技巧。)
No guarantee this will fix your problem, but if you want to disable the Nagle algorithm, you need to get the native socket from the stream and call
setsockopt
.(Shout out to Mike Ash for the compound literal trick.)