It reads all the data that is available on the networkstream or when the buffer is full. Whichever comes first. You have already noticed this behaviour.
So you will need to process all the bytes and see whether the message is complete. You do this by framing a message. See .NET question about asynchronous socket operations and message framing on how you can do this.
As for the timeout question, if assuming you are asking whether a beginread has a timeout, I would say no, because it is just waiting for data to arrive on the stream and put it into a buffer, after which you can process the incoming bytes.
The number of bytes available on the read action depends on things like your network (e.g. latency, proxy throttling) and the client sending the data.
BeginRead behaviour summary:
- Call BeginRead(); -> Waiting for bytes to arrive on the stream......
- 1 byte or more have arrived on the stream
- Start putting the byte(s) from step 2 into the buffer that was given
- Call EndRead(); -> The byte(s) within the buffer can be processed by EndRead();
- Most common practice is to repeat all these steps again.