You are encouraged to work in groups for this exercise.
To turn in this exercise, email the TA the answers to the questions in bold.
1. Give the URLs of the websites you have chosen, and the number of receive calls to obtain the home page of each of the websites.
If you do this exercise correctly, you should be able to see the HTTP response header sent by the server, as well as the content. You will need this information in Part 5. Some websites send back a lot of data -- you may need to scroll back or look around to find a website that sends less data.
I strongly recommend using strncat and strncpy rather than strcat or strcpy. As an alternative, feel free to use snprintf, as the instructor's code does.
Be sure your code can break a URL such as "http://manoa.hawaii.edu/records/calendar/index.html" into its components: the host name "manoa.hawaii.edu" and the path to request, "/records/calendar/index.html".
2. Turn in your code. If your code works, also report the number of receive calls to obtain "http://manoa.hawaii.edu/records/calendar/index.html".
Now modify the server to print each request, so that you can see what requests your clients are sending. Remember that data you get from the network is NOT null-terminated, that is, is NOT a C string. To make it a C string, you have to add the null character '\0' after all the data characters (this may already be in the code -- only do it if necessary). Check with the instructor or TA if you do not understand this.
3. Give the name of the web browser you used to connect to your server (Safari, IE, Firefox, etc), and state all the requests that the browser sent to the server. There may be only one request, or there may be more than one -- just observe carefully and report what the requests were.
4. Turn in your code for the modified server.
You may find documentation for the sockets API under the Unix/Linux
"man" pages. Most of the API
is in Section 2 (system calls), some functions such as
index are in
section 3, and address usage is in section 7 (IP and IPv6).
Computer Networks, ICS 451
Instructor: Edo Biagioni