Get Length of Data Available in NetworkStream

前端 未结 4 1868
臣服心动
臣服心动 2020-12-04 01:54

I would like to be able to get the length of the data available from a TCP network stream in C# to set the size of the buffer before reading from the network stream. There i

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-04 02:10

    There is no inherent length of a network stream. You will either have to send the length of the data to follow from the other end or read all of the incoming data into a different stream where you can access the length information.

提交回复
热议问题