Chat Application Protocol

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

Message
Sent by
Description

HELLO-FROM <name>\n

Client

First hand-shake message. The client sends this in an attempt to log in.

HELLO <name>\n

Server

Second hand-shake message. The server sends this if the handshake (i.e., log-in) is successful.

IN-USE\n

Server

Sent during handshake if the user cannot log in because the chosen username is already in use.

BUSY\n

Server

Sent during handshake if the user cannot log in because the maximum number of clients has been reached.

LIST\n

Client

Request for all currently logged-in users.

LIST-OK <name1>,...,<namen>\n

Server

A list containing all currently logged-in users.

SEND <name> <msg>\n

Client

A chat message for a user with username name. Note that the message cannot contain the newline character, because it is used as the message delimiter.

SEND-OK\n

Server

Response to a client if their ‘SEND’ message is processed successfully.

BAD-DEST-USER\n

Server

Sent in response to a SEND message to indicate that the destination user is not currently logged in.

DELIVERY <name> <msg>\n

Server

A chat message from a user with username name.

BAD-RQST-HDR\n

Server

Sent if the last message received from the client contains an error in the header.

BAD-RQST-BODY\n

Server

Sent if the last message received from the client contains an error in the body.

Last updated