Realm's protocol is a TCP connection on port 2050. Packets are sent in a HEADER + BODY format:
HEADER: int32 length int8 id
BODY depends entirely on the id.