.NET TCP服务器接收大团块每隔几分钟字节团块、几分钟、每隔、字节

2023-09-05 01:09:19 作者:赛高

背景:

在C#.NET同步TCP服务器 在一个TcpClient的目的是通过阻断一个的TcpListener与AcceptTcpClient方法分配 曾经有一个TcpClient的对象,我将它传递给一个线程调用客户端的GetStream方法来创建一个的NetworkStream 在此的NetworkStream环绕在,在每一次迭代做networkStream.Read(someBuffer,0,4096) 右键现在客户端和服务器都位于同一网络上,没有拥挤可言 在我的服务器有足够的内存来不遗余力 如果我在我的服务器软件加载到另一台机器,问题消失 起脚:从网络的Linux机器的流量获得通过罚款,而时间的 C# .net synchronous Tcp server a TcpClient object is assigned by blocking on a TcpListener with the AcceptTcpClient method once there's a TcpClient object, I pass it to a thread that invokes the client's GetStream method to create a NetworkStream this NetworkStream is looped over, in each iteration doing a networkStream.Read(someBuffer, 0, 4096) right now client and server are located on the same network, with no congestion to speak of my server has plenty of memory to spare if I load my server software onto another machine, the problem goes away the kicker: traffic from a network Linux box gets through fine and on time

我的服务器已经运行得很好了好几个月。然而,在过去的周末,而不是接受接二连三小团体字节的地方,过程开始(tcpListener.AcceptTcpClient())仅发生每隔几分钟。所以,我的服务器处于空闲状态,然后得到30-50客户端的请求都捆绑成一个字节块巨大。不用说,这导致了巨大的延迟,并把应变我的服务器上。如果客户端请求的丛足够大,就可以把我的服务器30分钟就追了上去。

My server has been functioning just fine for several months. However, over the past weekend instead of receiving small groups of bytes in quick succession, the place where the process begins ( tcpListener.AcceptTcpClient() ) only occurs every couple of minutes. So my server sits idle, then gets 30-50 client requests all bundled into one huge block of bytes. Needless to say this causes a huge delay and put strain on my server. If the clump of client requests is big enough, it can take my server 30 minutes to catch up.

在日志内置到我的客户,我可以看到他们做网络写入,而且每一个之间平齐。因此,客户端正常。

In logging built into my clients, I can see them do network writes, and flush between each one. So the clients are functioning correctly.

这reaks某种系统干预的。是我的TCP服务器(如上述)不好,或者说是一些在Windows与我的交通干扰,我怎么知道?

This reaks of some kind of system intervention. Is my Tcp server (as describe above) bad, or is something in Windows interfering with my traffic, and how can I tell?

谢谢你们。

推荐答案

您可能需要安装一些数据包捕获软件,每个TCP端点。你会惊讶。我患有类似的问题,现在,实际上几乎完全一致。

You might want to install some packet capture software at each Tcp endpoint. You'd be surprised. I'm suffering with a similar problem now, almost completely identical actually.

当我把采集软件的地方,我注意到,端点之间的交通非常快,并在预期的时间。

When I put capture software in place I noted that traffic between endpoints was fast and on time as expected.