Asynchronous TCP/IP, Part 3
This series: Live coding to https://github.com/StephenClearyExamples/TcpChat Developing an asynchronous TCP/IP server and client. Discussing TCP/IP protocol design. Discussing some harder concepts in async/await. Part 3: Using length prefixes for message framing. Adding length prefix and message type fields to the protocol. Defining message type 0 (Chat). Using System.IO.Pipelines to parse messages on the server. Note: 1:00:24 introduces a bug: it can call AdvanceTo multiple times on the same buffer if it has multiple messages. This bug was fixed after this series: https://github.com/StephenClearyExamples/TcpChat/commit/f4c8b1c5564ccc0a50f04f11fc93409df4d0e303 Code changes: https://github.com/StephenClearyExamples/TcpChat/compare/day-02...day-03 Resources mentioned in this video: ZeroMQ: https://zeromq.org/ Asynchronous Messaging: https://blog.stephencleary.com/2021/01/asynchronous-messaging-1-basic-distributed-architecture.html Introduction to SequenceReader (Steve Gordon): https://www.stevejgordon.co.uk/an-introduction-to-sequencereader SequenceReader source code: https://github.com/dotnet/runtime/blob/57bfe474518ab5b7cfe6bf7424a79ce3af9d6657/src/libraries/System.Memory/src/System/Buffers/SequenceReader.cs#L406 0:00 Intro 0:45 Answering questions and review of PipelineToSocketAsync 19:08 Using length prefixes for message framing 24:25 Defining the message type field 25:30 Defining Type 0 (Chat) messages 27:42 Sending Type 0 (Chat) messages with length prefix and message type 32:30 Testing binary prefixes without proper reading on the server 33:32 Using System.IO.Pipelines on the server for reading from the socket 41:43 Parsing messages using System.IO.Pipelines 1:03:37 Answering questions 1:04:53 Fixing the code 1:07:26 The code doesn't work (I fix it in part 4) 1:12:28 Outtro
Download
1 formatsVideo Formats
Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.