Practice ยท 1 of 2
A framed echo server
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.
Difficulty: advanced
Press Submit to check your solution.
Back to lesson: Practice: Socket drills