You need message framing. The protocol must specify how large the messages are – usually either a constant well-known size, a length prefix, or using message delimiters.
More Related Contents:
- Can a TCP c# client receive and send continuously/consecutively without sleep?
- Get Length of Data Available in NetworkStream
- An existing connection was forcibly closed by the remote host
- HttpClient.GetAsync(…) never returns when using await/async
- Running multiple async tasks and waiting for them all to complete
- In C#, how to check if a TCP port is available?
- Server Client send/receive simple text
- How to limit the Maximum number of parallel tasks in c#
- Task sequencing and re-entracy
- .NET Asynchronous stream read/write
- How does Task become an int?
- What is the correct way to read from NetworkStream in .NET
- Async and await – difference between console, Windows Forms and ASP.NET
- Benefits of using async and await keywords
- Do asynchronous operations in ASP.NET MVC use a thread from ThreadPool on .NET 4
- Why does the async keyword exist
- Why use async and return await, when you can return Task directly?
- Executing tasks in parallel
- Proper way to start and fire-and-forget asynchronous calls?
- Use Task.Run() in synchronous method to avoid deadlock waiting on async method?
- A pattern for self-cancelling and restarting task
- A pattern to pause/resume an async task?
- Converting async/await to Task.ContinueWith
- How to properly and completely close/reset a TcpClient connection?
- How to Async Files.ReadAllLines and await for results?
- Getting the location from a WebClient on a HTTP 302 Redirect?
- Sockets On Same Machine For Windows and Linux
- Await and SynchronizationContext in a managed component hosted by an unmanaged app
- Calling an async method from a synchronous method
- Marshal.PtrToStructure (and back again) and generic solution for endianness swapping