What if `in.read()` returns -1? This should probably throw an EOFException? Or a ProtocolException? Something is definitely wrong if that happens.