.net - Is it possible to determine whether a read from SecureStream will block? -
can determine whether reading single byte securestream
block? underlying stream networkstream
, has dataavailable
property, expect securestream
needs buffer bytes operate correctly, don't think can rely on underlying stream's dataavailable
.
alternatively, there way perform read
never block? i'm pretty sure there isn't; i've hated stream
api, maybe i'm missing something?
why: have tcp server implementation highly optimized paths handling requests. in particular, original code used beginread
every request, found replacing read
whenever data available (which happens time short requests) increased our maximum throughput more 20%. i'd same ssl variant of code.
i wonder why read
faster beginread
when data available. shouldn't drastic.
you can @ underlying stream's available data, , if it's more few bytes, can assume data available , use read
. otherwise, use beginread
. on safe side, set readtimeout
millisecond, won't block long in case miss.
but think real question why beginread slower in first place.
Comments
Post a Comment