【发布时间】:2012-07-02 20:21:54
【问题描述】:
我有一个接收数据并读取数据进行处理的套接字连接。
当数据处理/从套接字拉取的速度不够快时,TCP级别就会出现瓶颈,并且接收到的数据会延迟(我可以通过解析后的时间戳来判断)。
如何查看有多少 TCP 字节等待套接字读取? (通过一些外部工具,如 WireShark 或其他)
private void InitiateRecv(IoContext rxContext)
{
rxContext._ipcSocket.BeginReceive(rxContext._ipcBuffer.Buffer, rxContext._ipcBuffer.WrIndex,
rxContext._ipcBuffer.Remaining(), 0, CompleteRecv, rxContext);
}
private void CompleteRecv(IAsyncResult ar)
{
IoContext rxContext = ar.AsyncState as IoContext;
if (rxContext != null)
{
int rxBytes = rxContext._ipcSocket.EndReceive(ar);
if (rxBytes > 0)
{
EventHandler<VfxIpcEventArgs> dispatch = EventDispatch;
dispatch (this, new VfxIpcEventArgs(rxContext._ipcBuffer));
InitiateRecv(rxContext);
}
}
}
事实是,我猜“调度”会以某种方式阻止接收,直到它完成,最终导致延迟(即在调度被延迟时处理的数据,因此我的(错误?)结论是在套接字级别或之前累积的数据。
【问题讨论】:
标签: c# networking tcp