c# - Reading from NetworkStream. Which is better ReadLine() vs. Read into ByteArray? -
i using tcpclient communicate server sends information in form of "\n" delimited strings. data flow pretty high , once channel set, stream have information read from. messages can of variable sizes.
my question is, better use readline() method read messages stream "\n" delimited, or advisable read bytearray of fixed size , pick message strings them using split("\n") or such? (yes, understand there may cases when byte array gets part of message, , have implement logic too.)
points need considered here are:
performance.
data loss. data lost if client isn't reading fast data coming in?
- multi-threaded setup. if setup has implemented in multi-threaded environment, each thread have separate communication channel, share same resources on client.
if performance main concern prefer read on readline method. i/o 1 of slower things program can want minimize amount of time in i/o routines reading data front.
data loss not concern here if using tcp. tcp protocol guarantees delivery , deal congestion issues result in lost packets.
for threading portion of question we're going need bit more information. resources shared, sharing tcpclient's, etc ...
Comments
Post a Comment