COMP1521 18s1 COMP1521 18s1 Final Exam Comp Sys Fundamentals
[Instructions] [Documentation]
[Q1] [Q2] [Q3] [Q4] [Q5] [Q6] [Q7] [Q8] [Q9] [Q10]

Question 10 (4 marks)

Answer each of the following questions with one or two short, clear sentences:

  1. What is the purpose of a DNS server?

  2. What does the IP address 127.0.0.1 represent?

  3. Consider the following pseudo-code for a server based on Unix sockets:

    main() {
       s = socket(AF_INET, SOCK_STREAM, IP)
       serverAddr = {INTERNET,HostName,Port}
       bind(s, &serverAddr, Size)
       listen(s, QueueLen)
       while (1) {
          int ss = accept(s, &clientAddr, &Size)
          if (fork() != 0)
             close(ss)  // server not involved
          else {
             // child of server handles request
             close(s)
             // use ss to handle connection
             exit(0)
          }
       }
    }
    

    Give pseudo-code for a client program that connects to this server, sends a single request, and reads the response from the server.

Type your answers to this question into the appropriate place in the q10.txt file, and submit it using the command:

submit q10

This will make a copy of the q10.txt file as your answer for this question. You can run the submit command as many times as you like, but only the most recent submission will be marked.