什么情况会导致NetworkStream.Write阻止? [英] What conditions cause NetworkStream.Write to block?

查看:125
本文介绍了什么情况会导致NetworkStream.Write阻止?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

威尔 NetworkStream.Write 块只有等到它的地方将被发送到TCP发送缓冲区中的数据,还是会阻塞,直到数据实际上是由ACK'd ?接收主机

Will NetworkStream.Write block only until it places the data to be sent into the TCP send buffer, or will it block until the data is actually ACK'd by the receiving host?

注:插座被配置为阻塞I / O

Note: The socket is configured for blocking I/O.

修改: 哎呀,有没有这样的东西 TcpClient.Write 当然!我们都知道(),我们正在谈论 TcpClient.GetStream。写,这实际上是 NetworkStream.Write

Whoops, there's no such thing as TcpClient.Write of course! We all understood we were talking about TcpClient.GetStream().Write, which is actually NetworkStream.Write!

推荐答案

除非.NET是比使用其他的winsock的东西,然后再根据winsock的参考:

Unless .net is using something other than winsock, then according to the winsock reference:

发射功能的顺利完成并不表示数据已成功交付和接收到收件人。此功能仅指示数据已成功发送。

The successful completion of a send function does not indicate that the data was successfully delivered and received to the recipient. This function only indicates the data was successfully sent.

如果没有缓冲空间的输送系统内可保持要发送的数据时,发送将阻止,除非该插座已被放置在非阻塞模式。上非阻塞面向流插座,写入的字节的数目可以在1和请求的长度之间,这取决于在客户端和服务器计算机上缓冲器的可用性。

If no buffer space is available within the transport system to hold the data to be transmitted, send will block unless the socket has been placed in nonblocking mode. On nonblocking stream oriented sockets, the number of bytes written can be between 1 and the requested length, depending on buffer availability on both the client and server computers.

假设写在呼唤送下,然后在Winsock文​​件的严格解释将表明,没有出示担保,使得该数据它时,它返回管道的另一端。

Assuming that write is calling send underneath, then a strict interpretation of the winsock documentation would indicate that there is no gurantee that the data made it to the other end of the pipe when it returns.

下面是链接到winsock的文档我从报价:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms741416(v = VS.85)的.aspx

Here is the link to the winsock docs I am quoting from: http://msdn.microsoft.com/en-us/library/windows/desktop/ms741416(v=VS.85).aspx

这篇关于什么情况会导致NetworkStream.Write阻止?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆