Skip to content

Instantly share code, notes, and snippets.

@zao
Created March 18, 2012 04:22
Show Gist options
  • Save zao/2068876 to your computer and use it in GitHub Desktop.
Save zao/2068876 to your computer and use it in GitHub Desktop.
TOY protocol description
Messages begin with one octet of message tag.
Primitives
==========
sized-string: one octet of size followed by that many printable low-ascii characters
Client -> Server
================
0x3F: HELLO
Payload: username :: sized-string
Meaning: Register connection with human-readable user-name, required to be allowed to send and receive chat.
0x3E: I-SAY
Payload: chatmessage :: sized-string
Meaning: Message to broadcast to everyone, excluding client.
Server -> Client
================
0x3C: HE-SAID
Payload: username :: sized-string
chatmessage :: sized-string
Meaning: Message from another user.
Additional semantics
====================
When an user attempts to send a message without being registered, disconnect him.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment