> For the complete documentation index, see [llms.txt](https://computer-networks-lab.gitbook.io/computer-networks-lab-manual/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://computer-networks-lab.gitbook.io/computer-networks-lab-manual/appendix/chat-application-protocol.md).

# Chat Application Protocol

The table below shows the protocol of the chat application used in the Lab.

<table><thead><tr><th width="285">Message</th><th width="99">Sent by</th><th>Description</th></tr></thead><tbody><tr><td><code>HELLO-FROM &#x3C;name>\n</code></td><td>Client</td><td>First hand-shake message. The client sends this in an attempt to log in.</td></tr><tr><td><code>HELLO &#x3C;name>\n</code></td><td>Server</td><td>Second hand-shake message. The server sends this if the handshake (i.e., log-in) is successful.</td></tr><tr><td><code>IN-USE\n</code></td><td>Server</td><td>Sent during handshake if the user cannot log in because the chosen username is already in use.</td></tr><tr><td><code>BUSY\n</code></td><td>Server</td><td>Sent during handshake if the user cannot log in because the maximum number of clients has been reached.</td></tr><tr><td><code>LIST\n</code></td><td>Client</td><td>Request for all currently logged-in users.</td></tr><tr><td><code>LIST-OK &#x3C;name1>,...,&#x3C;namen>\n</code></td><td>Server</td><td>A list containing all currently logged-in users.</td></tr><tr><td><code>SEND &#x3C;name> &#x3C;msg>\n</code></td><td>Client</td><td>A chat message <em>for</em> a user with username <code>name</code>. Note that the message cannot contain the newline character, because it is used as the message delimiter.</td></tr><tr><td><code>SEND-OK\n</code></td><td>Server</td><td>Response to a client if their ‘SEND’ message is processed successfully.</td></tr><tr><td><code>BAD-DEST-USER\n</code></td><td>Server</td><td>Sent in response to a SEND message to indicate that the destination user is not currently logged in.</td></tr><tr><td><code>DELIVERY &#x3C;name> &#x3C;msg>\n</code></td><td>Server</td><td>A chat message <em>from</em> a user with username <code>name</code>.</td></tr><tr><td><code>BAD-RQST-HDR\n</code></td><td>Server</td><td>Sent if the last message received from the client contains an error in the header.</td></tr><tr><td><code>BAD-RQST-BODY\n</code></td><td>Server</td><td>Sent if the last message received from the client contains an error in the body.</td></tr></tbody></table>
