NetworkStream Read 在死亡之前会等待多长时间?

发布于 2024-08-28 23:57:15 字数 197 浏览 4 评论 0原文

我在 NetworkStream 对象上调用了 Read,它在内部使用 Socket.Receive

假设没有数据进入。读取方法退出之前需要多长时间? ReceiveTimeout 设置为 0(无限超时)。

如果我拔掉网线怎么办?会退出吗?

I have a call to Read on NetworkStream objeck, which uses Socket.Receive internally.

Say that no data is comming in. How long before the Read Method exits?
ReceiveTimeout is set to 0 (infinite timeout).

What if I unplug the internet cable? Will it exit?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦中的蝴蝶 2024-09-04 23:57:15

如果拔掉电缆,您将收到IOException
如果另一端的套接字关闭,您将收到此异常。

如果存在网络问题,您可能会收到ObjectDisposeException
更多信息请参见这篇 MSDN 文章。

否则它可能会运行大约 8 年,正如 Hans 指出的:)

If you unplug the cabel you will get IOException.
You'll get this exception if socket is closed on the other end.

You might get an ObjectDisposedException if there is a network problem.
More info in this MSDN article.

Otherwise it might run for around 8 years, as Hans pointed out :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文