1. Homepage
  2. Programming
  3. [2021] UIC - CS 361: Systems Programming - Homework5 Web based Chat Server

[2021] UIC - CS 361: Systems Programming - Homework5 Web based Chat Server

Engage in a Conversation
CS361Systems ProgrammingUniversity of Illinois at ChicagoUICWeb based Chat Server

Homework 5 a web based chat server#

Assignment checkout link.

In this assignment, you will be finishing a super basic, but totally functional, web-based chat program. The main challenge for students will be to digest the code as given, and write the logic that makes the stateful protocol run. Watch this video to see the solution code in action. CourseNana.COM


CourseNana.COM

HTTP routes#

The server itself functions as a standard HTTP server. Where the previous homework required you to serve files and run external programs based on each request, this server functions more as a web application in that the server will be performing actions itself based on requests: sometimes it will send a file, sometimes it will send chat messages, sometimes it will receive chat messages and then send them to all listening clients. CourseNana.COM

In a modern web application, rather than simply serving files, these different actions are called routes. The routes in our application are: CourseNana.COM

  1. GET /index.html just sends the static index file.
  2. GET /listen set up a "server-sent events" connection, where newly received messages are sent.
  3. POST /speak the web browser makes this request when a user wants to send a chat message, and the received message is broadcast to all listening clients.

Server-sent events#

Generally, "asynchronous" communication between an http server and an http client is somewhat complicated. Thankfully, server-sent events make this simple: by sending a response with mime type text/event-stream, the browser knows to continually read bytes from that socket and interpret them as empty-line-delimited individual messages, similar to how HTTP headers and HTTP bodies are separated. CourseNana.COM

Another nice aspect of how the browser works is that it can make multiple requests simultaneously through different file descriptors. So once it receives index.html, it can then make one long-lived HTTP connection to the /listen endpoint, waiting for new messages to appear, and then make separate connections and send messages to the /speak endpoint when the client wants to send a message. CourseNana.COM

Skeleton code#

The skeleton code for this assignment is based off of the event-driven, single-threaded echo server in the book. All of the code for receiving multiple connections is still in there. The TODOs for this assignment happen when a new message comes in on an individual socket: you need to decide on what to do next in order to move the protocol forward. Each time that bytes are received, they should be accumulated into requestbuf for that specific client. CourseNana.COM


CourseNana.COM

My suggested strategy#

My TODO solutions are 4 and 29 lines long respectively - the vast majority of the difficulty in this assignment is understanding what you need to do, understanding what the skeleton code does, and then using the helper functions already written to add the correct code. The skeleton code itself is based off of the select-based echo server that's presented in the book. I would recommend reading that section of the book, paying extra attention to how the select server was written, and then move forward from there. The main thing that makes this more complicated is that the echo server doesn't require any statefulness (do different on a given connection based on what information you've received previously), and it doesn't require any interaction between different socket connections. CourseNana.COM


Get in Touch with Our Experts

WeChat WeChat
Whatsapp WhatsApp
CS361代写,Systems Programming代写,University of Illinois at Chicago代写,UIC代写,Web based Chat Server代写,CS361代编,Systems Programming代编,University of Illinois at Chicago代编,UIC代编,Web based Chat Server代编,CS361代考,Systems Programming代考,University of Illinois at Chicago代考,UIC代考,Web based Chat Server代考,CS361help,Systems Programminghelp,University of Illinois at Chicagohelp,UIChelp,Web based Chat Serverhelp,CS361作业代写,Systems Programming作业代写,University of Illinois at Chicago作业代写,UIC作业代写,Web based Chat Server作业代写,CS361编程代写,Systems Programming编程代写,University of Illinois at Chicago编程代写,UIC编程代写,Web based Chat Server编程代写,CS361programming help,Systems Programmingprogramming help,University of Illinois at Chicagoprogramming help,UICprogramming help,Web based Chat Serverprogramming help,CS361assignment help,Systems Programmingassignment help,University of Illinois at Chicagoassignment help,UICassignment help,Web based Chat Serverassignment help,CS361solution,Systems Programmingsolution,University of Illinois at Chicagosolution,UICsolution,Web based Chat Serversolution,