Good afternoon,
OK, short and sweet.
I need to get the number of bytes available for read from a socket. I have setup a NetworkStream on my Socket Client but can't seem to find how to get the number of bytes that are available to be read, at the moment I can only get a boolean stating "Yes I have Bytes", or "No Bytes this time". But this is all but useful for the task I require.
Could anyone put me out of my misery and provide me with my need?
Thanks in advance, appreciated.
As specified in this MSDN article about the NetworkStream.Length
property:
Gets the length of the data available on the stream. This property always throws a
NotSupportedException
.
This is due to the fact that data is fed to the stream as it arrives, thus having no actual length.
However, the Socket.Available
property tells you how many bytes are available to be read at this exact moment. The value may change at any given time if new data arrives.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With