开发者

How long will NetworkStream Read wait, before dying?

开发者 https://www.devze.com 2022-12-26 21:23 出处:网络
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?

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?


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 :)

0

精彩评论

暂无评论...
验证码 换一张
取 消