CSE 124
2017 October 27: Project 1 FAQ

Oct 31

  • What address should I bind my server to?

    • INADDR_ANY or AI_PASSIVE.
    • Ensure that you’re able to connect both from the same ieng6 (using localhost) and a different ieng6 machine.
  • What marks the end of a request? A response?

    • Requests and responses always have after the last header, as detailed in the project writeup.
    • For this project, requests will never contain a body. This means after seeing , the server has the entire request.
    • There is no additional after a message body. The length of the body is solely denoted by the “Content-Length” header.
    • There is only one per request/response, which is after the last header.
  • How does the “Connection: close” header work in action?

    • A request containing a “Connection: close” header is still a request. There may be additional headers after the “Connection: close” header, and the client must receive a response from the server.
    • After the response is sent, the server then closes the connection with the client.

Oct 27

  • Do we need to use mutex or any locking mechanisms for this project?

    • Not really, you can implement it successfully without having any locks.
  • What all possible filetype requests can be made to the server?

    • Valid file(content) type would be .jpg, .png, .html ONLY
    • NOTE: GET / translates to GET /index.html
  • Do we have to check HTTP version from the client?

    • Yes, it must be HTTP/1.1. If not, the server would return a 400 Client Error.
  • What will be host parameter in HTTP request header?

    • This is a mandatory field and should be set to sever IP. You dont have to really cross check on the server if this value is set to server IP address. Just checking if something is present while parsing is fine.
  • What will be the HTTP request header size?

    • Ideally it should not matter. But you can assume cumulative HTTP requests are not larger than 8KB.
  • Can we wait for all the threads to complete before accepting new clients?

    • No, your server should accept clients if any of the thread from the thread pool is free. You should NOT wait for ALL clients to be served before accepting new connections.
  • How many maximum clients should server process at once?

    • Not many, may be roughly 5. We would not be testing with a lot of clients contacting server at the same time.

Oct 20

In some of the example code used in class/the book, there is an infinite loop on the server that looks similar to:

for(;;){ //run forever
	int clientSocket = AcceptTCPConnection(servSocket);
	HandleTCPClient(clntSock);
	close(clntSock);
	break;   <---- remove this
}

The break indicated should be removed to keep the server running across many clients.

Oct 18

The due date for project 1 has been extended by 1 week to Friday Nov 3rd, 5pm.

Oct 18

For the security part of project 1, you need to read in the contents of a file called “.htaccess” (if it exists), and apply the rules to see if the client matches any of the allow/deny rules.

For this project, this access checking process is not recursive. This means that if your webserver’s document root is “/tmp/htdocs”, and a client requests the file “/images/animals/pets/cat.jpg”, then your server should look to see whether the file “/tmp/htdocs/images/animals/pets/.htaccess” exists, and if it does, read in the rules and apply them. If not, just serve out ‘cat.jpg’.

You do not need to check if /tmp/htdocs/.htaccess exists, then /tmp/htdocs/images/.htaccess, etc. Just look in the directory with the file requested.

Oct 18

On most (all?) UNIX systems, ports under 1024 are reserved for system processes, and typically require administrator/root access to bind() to. For this class, please use ports higher than 1024.

Oct 11

sendfile()

For project 1, you are going to need to copy data from on-disk files to a network socket, to send the contents of images and/or HTML files to the client. One option is to read data in fixed-sized chunks, which is a fine solution for this project. Another option is to use the sendfile() system call, which will do that data copying for you. To learn about this call, type man sendfile on the lab computers.

Client and server examples posted

I’ve posted examples of a client and a server program to: https://github.com/gmporter/cse124-lec06-webserver

You can use this client to test your web server, BTW. Feel free to re-use this code in your project if you want.

Oct 10

Minimal autograder

A minimal version of the project 1 autograder has been posted to $PUBLIC/project1 on the ieng6 servers. You can run this against your web server using the htdocs directory that is also in $PUBLIC/project1 to check that the basic request/response handling is working correctly.

Checking for ‘world readable’ files

You can use the fstat() command to check the status of files on the filesystem. In particular, look for the S_IROTH flag to see if the file is world readable.