pete > courses > CS 315 Fall 26 > Assignment 7


Assignment 7

If any of this is unclear, please get in touch with me ASAP. There are definitely things in the course I want you to struggle with. I absolutely do NOT want you struggling to understand my expectations.

In this assignment, you will implement both server and client for a simple online chat system. Every client will represent a user, which may have a name associated with it. Upon connecting, the name will be "unknown", but a user may change their name by sending the message "/nick <new nickname>" to the server. The server will announce the name change to all connected clients. Similarly, any message sent by a client will appear for all clients.

Following are example runs of a single server and two separate clients running concurrently.

Server (all text output by server process, pressed Ctrl-C after first client exited):

$ ./chat-server 8000
new connection from 127.0.0.1:46814
new connection from 127.0.0.1:46816
User unknown (127.0.0.1:46814) is now known as foo.
User unknown (127.0.0.1:46816) is now known as bar.
Lost connection from foo.
^C

Client 1 (the lines consisting of only "/nick foo", "hi", and "I’m just fine, thanks" were input at the terminal, followed by Ctrl-D):

$ ./chat-client localhost 8000
Connected
/nick foo
22:31:37: User unknown (127.0.0.1:46814) is now known as foo.
22:31:41: User unknown (127.0.0.1:46816) is now known as bar.
hi
22:33:40: foo: hi
22:33:42: bar: hello!
22:33:45: bar: how are you?
I'm just fine, thanks
22:33:48: foo: I'm just fine, thanks
Exiting.

Client 2 (the lines consisting of only "/nick bar", "hello!", and "how are you?" were input at the terminal, exited when server terminated):

$ ./chat-client localhost 8000
Connected
22:31:37: User unknown (127.0.0.1:46814) is now known as foo.
/nick bar
22:31:41: User unknown (127.0.0.1:46816) is now known as bar.
22:33:40: foo: hi
hello!
22:33:42: bar: hello!
how are you?
22:33:45: bar: how are you?
22:33:48: foo: I'm just fine, thanks
22:34:01: User foo (127.0.0.1:46814) has disconnected.
Connection closed by remote host.

New Mechanics

You might find these useful in this assignment.

New(ish) functions

(In addition to those functions introduced in the various course notes.)

New machines

You have used basin.cs.middlebury.edu already in this course to store your upstream git repos. Unfortunately, as we discovered in class, the firewall on basin does not allow arbitrary incoming network connections, and so you won’t be able to use it to test your chat server. The good news is that there is another machine available for this purpose: you may ssh to weathertop.cs.middlebury.edu and run your servers there. weathertop accepts incoming connections on ports 4000 through 4020, so use a port in that range. Recall that multiple sockets can’t bind to the same port; you can use the command netstat -tnl to see which ports are in use. If you are off-campus, you will need the VPN active to connect to weathertop, just as you do for basin.

Behavioral requirements

For the server…

For the client…

For the system…

Deliverable requirements

Style requirements

Your code must exhibit:

Submission Process

Your submission files should be in a git repository on basin in this directory:

/home/<username>/<secret>/assignment7

Email me when you want feedback, with a description of the type of feedback you would like.

Last modified: