Networking checkpoint
Challenge on lesson: Checkpoint: networking
CHALLENGE
Difficulty: advanced+25 XP
Implement length-prefix framing on in-memory buffers (loopback-independent, deterministic): static byte[] EncodeFrame(string payload) โ 4-byte little-endian length prefix followed by UTF-8 bytes; static string DecodeFrame(ReadOnlySpan<byte> data) โ reads the prefix, validates that data.Length >= 4 + length (throw ArgumentException otherwise), decodes exactly length bytes. Then implement static async Task<string> EchoProtocol(string message): start a TcpListener on an ephemeral loopback port, accept one client, read one frame, echo the payload back framed, and return what the client received. The sandbox's loopback TCP is verified working.
Press Submit to check your solution.
Back to lesson: Checkpoint: networking