可以在发送之前获取TCP/IP数据包吗?

可以在发送之前获取TCP/IP数据包吗?

问题描述:

在同一台机器上运行着一个客户端和一个服务器应用程序。 他们使用与TcpClient和TcpListener的异步通信。可以在发送之前获取TCP/IP数据包吗?

服务器应用程序在后台工作线程中执行一些数据处理。每当处理每个数据部分时,都会尝试使用TcpListener发送它,如果有任何客户端连接到它并且发送了请求来获取已处理的数据部分。

在BeginWrite函数调用服务器设置客户端标志后立即避免发送新数据,直到客户端将发送另一个请求。作为请求TcpClientDataReadAsyncCallback到达()一个标志设置为客户端,以便背景工人可以将数据发送到客户端

这里是服务器的日志和客户端

server 

00.37.35.772 127.0.0.1:6012 recv 257 bytes of client Request 634538758557701309 
00.37.35.860 127.0.0.1:6012 sent 175652 bytes to client 
00.37.35.892 127.0.0.1:6012 recv 257 bytes of client Request 634538758558675330 
00.37.35.952 127.0.0.1:6012 sent 188927 bytes to client 
00.37.35.983 127.0.0.1:6012 recv 257 bytes of client Request 634538758559585382 
00.37.36.052 127.0.0.1:6012 sent 174790 bytes to client 
00.37.36.083 127.0.0.1:6012 recv 257 bytes of client Request 634538758560595440 
00.37.36.153 127.0.0.1:6012 sent 188491 bytes to client 
00.37.36.187 127.0.0.1:6012 recv 257 bytes of client Request 634538758561605498 
00.37.36.249 127.0.0.1:6012 sent 178723 bytes to client 
00.37.36.280 127.0.0.1:6012 recv 257 bytes of client Request 634538758562491540 
00.37.36.373 127.0.0.1:6012 recv 257 bytes of client Request 634538758563739542 
00.37.36.436 127.0.0.1:6012 sent 191229 bytes to client 

client 

00.37.35.864 127.0.0.1:6012 recv 175652 bytes of server Response 634538758558455318 
00.37.35.867 127.0.0.1:6012 sent 257 bytes Request to server 634538758558675330 
00.37.35.957 127.0.0.1:6012 recv 188927 bytes of server Response 634538758559455375 
00.37.35.959 127.0.0.1:6012 sent 257 bytes Request to server 634538758559585382 
00.37.36.056 127.0.0.1:6012 recv 174790 bytes of server Response 634538758560455432 
00.37.36.059 127.0.0.1:6012 sent 257 bytes Request to server 634538758560595440 
00.37.36.158 127.0.0.1:6012 recv 188491 bytes of server Response 634538758561465490 
00.37.36.160 127.0.0.1:6012 sent 257 bytes Request to server 634538758561605498 
00.37.36.249 127.0.0.1:6012 recv 178723 bytes of server Response 634538758562491540 
00.37.36.249 127.0.0.1:6012 sent 257 bytes Request to server 634538758562491540 
00.37.36.373 127.0.0.1:6012 recv 191229 bytes of server Response 634538758563583542 
00.37.36.373 127.0.0.1:6012 sent 257 bytes Request to server 634538758563739542 
00.37.41.412 client timed out RX operation 

00.37.35.772为hh: MM:SS:MS

634538758557701309号在线路末端的请求/响应对象的时间戳来整理他们在日志中

正如你所看到的一切,在适当的时候运行,直到191229个字节对象到达befo它被发送。在收到响应之前,客户端不会发送新的请求。我无法理解这是如何可能的。

完全有可能它是日志记录的人工产物。它可能是一些其他线程在发送数据之后但在将日志放下之前中断服务器线程。

+0

问题是客户端没有得到服务器响应后,毛刺'客户端超时RX操作'因为2请求到达,服务器只响应一个 –