Socket.Send 有延迟吗?
我正在构建一个应用程序并将数据发送回另一端,
在我的应用程序中,我有:
System.Net.Sockets.Socket.Send(byte[]) 函数。
我的客户告诉我,接收此数据包有 530 毫秒的延迟
。但是,我记录了所有位置,直到: System.Net.Sockets.Socket.Send(byte[])
我测量到从 Socket 发送数组大约需要 15 毫秒。我的客户建议我检查:
- 发送后刷新,但我在 Socket 中没有看到
flush 函数
? - 在发送之前填充数据缓冲区,否则,如果数据很短,那么我必须
强制传输
此建议之一是否正确?我看到Send方法还有另一个参数,即:SocketFlags
<= 使用这个SocketFlags
有什么帮助吗?
I am building an application and sending data back to the other side,
In my application, I have:
System.Net.Sockets.Socket.Send(byte[])
function.
My customer told me that there is 530 ms delay
of receiving this packet. However, I have logged every where until: System.Net.Sockets.Socket.Send(byte[])
I measured that it took about 15ms to get to send an array from Socket. My customer advised me to check:
- To flush after sending, but I dont see a
flush function
in Socket? - Fill up the data buffer before sending out otherwise, if the data is short, then I have to
force the transmission
Is one of this advice correct? I see there are also another parameter of the method Send, which is: SocketFlags
<= Is there any help of using this SocketFlags
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Nagle 算法存在一个常见问题,即尝试将一起发送的数据“粘合”到单个数据包中。您的代码也可能受到此问题的影响。
尝试按此处所示禁用它或通过设置
SocketOptionName.NoDelay
选项与SetSocketOption
方法。There's common problem with Nagle algorithm that tries to 'glue' data sent together into single packet. It is possible that your code suffers from it as well.
Try to disable it as shown here or by setting
SocketOptionName.NoDelay
option withSetSocketOption
method.