LMU ☀️ CMSI 355
COMPUTER NETWORKS
HOMEWORK #2 Due: 2019-03-28

Read, Watch, or Skim

I’ve selected some good materials to complement the lectures, problem sets, and programming projects; don’t skip them. (Short on time? Watch videos at 1.5x or faster.)

Please watch:

Please skim:

Please read:

Instructions

You will be adding to repository you created earlier, ending up with the following structure:

  .
  ├── README.md
  ├── .gitignore
  ├── homework1
  │   └── Files for Homework 1
  └── homework2/
      ├── short-answer-problems.md
      └── javascript/
          ├── random_number_server.js
          ├── random_number_client.js
          ├── random_number_web_server.js
          ├── chat_server.js
          └── chat.html

Submit your work as a GitHub Pull Request. Make sure the PR is produced by 23:59 in the America/Los Angeles time zone on the due date. (You can produce the PR by doing all your work on a branch, then clicking the New Pull Request button in GitHub.) I will grade by commenting on your PR.

Project Setup

Since your GitHub repo was set up in an earlier assignment, there are only a few things you need to do for this one.

  1. Create the homework2 folder
  2. Add to your .gitignore file a line for node_modules and anything else that becomes necessary.
  3. Continue by answering the problems and writing the assigned scripts below. Work on a branch and make a PR before submitting.

Make sure you use an IDE with a built-in linter or use VSCode or Atom with the proper plugins and linters. You are too experienced to be turning in un-linted code.

Short Answer Problems

Write the answers to the following in nice markdown format and submit in short-answer-problems.md

In Comer, 5th edition, do problems 1-7, 9-23 at the end of Chapter 3.

JavaScript Applications

Submit answers to the following, in your javascript folder. Please use a very recent version of Node. Write your code using very modern JavaScript; TypeScript is fine as well. If you are using Socket.IO, use version 2 or higher.

  1. A simple random number server, running on port 53211. As soon as a client connects, the server sends back a random integer, and that’s it. (Submit in random_number_server.js.)
  2. A command line client for the random number server, that connects to the server, gets its random number, prints it, then exits. The server IP address should be the first command line argument, accessible as process.argv[2].(Submit in random_number_client.js.)
  3. A web server that returns a random number at its /random endpoint, and delivers an HTML client at the / endpoint. The client must have a button to make a request: when clicked, the request is made and your app should display the response. You don’t have to spend a lot of time making the client beautiful, but a bit of effort (and perhaps humor) will be appreciated. (Submit in random_number_web_server.js and perhaps additional files, if you cannot stomach inline scripts.) You can do this in raw Node.js, or use a framework like Express.
  4. Implement a chat server. Begin by porting the ChatServer that I previously wrote in Java to JavaScript, but using WebSockets instead of being a straight TCP Server. Then add at least 5 “commands,” i.e., keywords beginning with / that when sent to the server, do cool things. One of these should be /quit but think of others. Also, send nice error messages to clients (such as when the chat room is full) and make sure your server never crashes. (Submit in chat_server.js.)
  5. Write a chat client (for the server in the previous problem) that runs in the browser. (Submit in chat.html and additional files as you desire.)