简体   繁体   中英

NetworkStream ReadTimeOut

I would like to understand how readtimeout works. In my case, my readtimeout is 20ms . So, does it mean that readtimeout will always wait for 20ms eventhough I receive my data in 5ms?

ns.ReadTimeout = 20;

No. Accoring to MSDN it is the time in milliseconds after which the operation will throw an IOException .

A Int32 that specifies the amount of time, in milliseconds, that will elapse before a read operation fails. The default value, Infinite, specifies that the read operation does not time out.

If the read operation does not complete within the time specified by this property, the read operation throws an IOException.

If the operation completes before that, there will be no additional delay.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM