...but not it's obvious - we can't assume each packet nicely encapsulates a single stage, it might all arrive in one go. So the current "recv" implementation can't work. d'oh!
Now isolated for easy re-use. Should split it into a separate library.