Please meet with your group members and get started on the lab as soon as possible. In general, in this class you will have about 2 weeks from the lab release date until the due date.
I have created a Git repository for each group. You should have already received an invite to access your repository on LoboGit. If you did not receive such an invite, contact me immediately.
The name of your repository will be teamXX, where XX are digits. You should be able to view the repository online at https://lobogit.unm.edu/net-f18/lab1/teamXX.
You will use the git tool on Linux to access the repository. First make sure to tell Git who you are:
git config --global user.name "YOUR NAME"
git config --global user.email "NETID@unm.edu"
git config -l
Now, there are two options for creating a local copy of your repository (choose only one of the following):
1 - Cloning the Repository via HTTPS (Easy)
This is the easiest method of accessing your repository. Git will prompt you for your UNM NetID/password.
cd ~
mkdir -p net-f18
cd net-f18
git clone https://lobogit.unm.edu/net-f18/lab1/teamXX.git lab1
cd lab1
Here, you should be able to type "ls" (list files) and see the skeleton structure which your lab 1 submission should follow.
2 - Cloning the Repository via SSH (More Difficult)
If you don't wish to type your NetID/password, you can instead use public-key authentication. First (if you haven't already done so), you need to create a key pair for public-key authentication (git will use this instead of username/password for authentication).
mkdir -p ~/.ssh
chmod 700 ~/.ssh
cd ~/.ssh
ssh-keygen -t rsa -b 4096 -C "YOUR_ADDRESS@unm.edu" -f id_rsa
(where YOUR_ADDRESS@unm.edu is your UNM email address). This creates a public key (id_rsa.pub) and a private key (id_rsa). KEEP YOUR PRIVATE KEY SECURE AT ALL TIMES! Open the public key (id_rsa.pub) in a text editor
pluma ~/.ssh/id_rsa.pub
and copy the contents into the "SSH Keys" section of your "Settings" on LoboGit. Once the public key is added on LoboGit, you can do
cd ~
mkdir -p net-f18
cd net-f18
git clone git@lobogit.unm.edu:net-f18/lab1/teamXX.git lab1
cd lab1
Here, you should be able to type "ls" (list files) and see the skeleton structure which your lab 1 submission should follow.
In the first part of this lab, you will design your own simple protocol, in order to complete the skeleton Java Client/Server code, resulting in a working chat client/server -- basically a highly-simplified version of Discord or AIM. When completed, you should be able to run a single server, connect several different clients, and chat with everyone else using that server.
Currently, the server just prints out any commands it receives, and the client just sends "placeholder" commands. Your job will be to architect a set of commands that (1) allows the client to tell the server about a newly-typed message, and (2) allows the client to request all unseen messages from the server.
You can compile the code like this:
javac *.java
and run the server in a separate terminal:
java ChatServer 8080
and then start a client that connects to the server:
java ChatClient hostname 8080
(where hostname is the address/name of the machine the server is running on, or "localhost" if it's running locally).
Use the Linux Sockets C API to write a simple HTTP client and server.
To use the client, I should be able to type:
client http://www.unm.edu/ 80
and see the HTML code for the corresponding webpage. The first command-line argument is a URL, and the second argument is a numeric port. You can assume that the URL always begins with "http://".
Similarly, if I create a simple HTML file, and run the server on my local machine:
echo "<html><h1>Hello</h1></html>" > index.html
server . 8080
I should be able to go to my browser and type "localhost:8080/index.html" and see the formatted HTML page. The first command-line argument to the server is a local directory, which will be used as the servers root directory, and the second argument is a port to listen on.
In Linux, "." means the current directory, so in the above example, when the server receives a request for "/index.html", it looks in the current directory for index.html.
Note that your client and server also need to work together, i.e., I should be able to request files from your server using your client. Note also that the server should be able to handle multiple subsequent requests without exiting. That is, I should be able to run the client several times in a row, and obtain the correct files from the server.
The C header files on Linux are a bit hard to keep track of, but there are some online resources which can be helpful. There are several other useful guides regarding programming with Sockets.
The HTTP 1.0 Spec is very long and detailed, but may be useful.
Clearly document (using source-code comments) all of your work. Also fill in the README.md file (preferably using Markdown syntax) with a brief writeup about the design choices you made in your code.
Providing adequate documentation helps me see that you understand the code you've written.
What are the calls that block in your C server? Make a second version of your C server (name it "server2.c"), and use the select function to avoid some of the blocking which occurs in your first server (accept blocks, for example).
I will automatically grab a snapshot of the master branch of your Lab 1 repository at the deadline.
Make sure you push all of your work before the deadline!
I should be able to type "make" in the main directory, and that should build all of the tools for me. Be sure to set up the Makefile as needed.