You can assume the following throughout this assignment:
● The FIN bit will always be 1 and you’ll read the entire frame in one read from your TCP socket (no
● The 3 reserved bits will always be 0
● You can ignore any frames with an opcode that is not 1
● Additional WebSocket headers are compatible with what we discussed in class (ie. You don’t have to
check the Sec-WebSocket-Version header)
Objective 1: WebSocket Handshake
Implement the WebSocket handshake and create a WebSocket in your client to establish a connection.
When this objective is complete you should see the request in your browser that receives a 101 response
containing the correct Sec-WebSocket-Accept header value.
Objective 2: Receive Frames
Add a form to your front end that your clients can use to send messages to your server via WebSocket
frames and parse these frames on your server. This objective will include parsing the bit values of the frame,
extracting and applying the mask, and reading the message. For full credit you must handle payload lengths
If you do not complete objective 4, add a way to test this functionality in your documentation.
Objective 3: Send Frames
Add functionality to send WebSocket frames to a client. For this objective a message can be sent back to a
client each time you receive a frame from them.
If you do not complete the next objective, add a way to test this functionality in your documentation.
Objective 4: Broadcast Messages
Each time you receive a WebSocket frame from any client, send this message via WebSockets to all
connected clients and have each client display the message in their browser.
To complete this objective you must store a reference of TCP socket that has been upgraded to a
WebSocket connection so you can send this frame to each connected user.
To earn credit for this homework you must complete all 3 submissions.
1. Submit all the files of your site to AutoLab in a zip file
2. Submit your report to AutoLab as a txt file
3. Fill out the homework self-grading form