Practice · 1 of 2
A framed echo server
CHALLENGE
Difficulty: advanced+25 XP
1. static String frame(String message) — return the wire form: message + "\n".
2. static java.util.List<String> deframe(String received) — split a received chunk
into complete frames: split on "\n" and DROP a trailing fragment that lacks its
terminator (an incomplete frame is not a frame). Empty input → empty list.
3. static byte[] lengthFrame(String payload) — binary framing: 4-byte big-endian
length prefix followed by UTF-8 payload bytes.
4. static int prefixLength(byte[] framed) — read the 4-byte big-endian prefix back.
Press Submit to check your solution.
Back to lesson: Practice: Socket drills