5570: Advanced Unix Programming

Midterm 2 review

Note:

You are responsible for learning material from the reading assignments, class notes, examples, and programming assignments. I give below some important topics that you should pay particular attention to. I have also listed some questions in here. That does not mean that these questions will appear directly in the exam. You need to understand the issues addressed by these questions, and be prepared to apply this understanding in different situations too. Of course, not all the topics mentioned below may appear in the exam, and there may be questions from topics not mentioned below.

Introduction to Unix network programming (UNP chapters 1 and 2)

  1. What are some protocols that we have discussed in class?

  2. Which version of IP have we used in our examples?

  3. What are the important differences between TCP and UDP?

  4. Do you know the TCP connection establishment and termination sequences?

  5. Do you know the relationship between socket related system calls, and corresponding actions that take place in the TCP layer in the kernel.

  6. Do you know what information uniquely identifies a TCP connection?

  7. Can two different servers bind to the same port number with the same IP address, if one uses UDP and the other TCP?
Sockets and TCP (UNP chapters 3, 4 and 5)

  1. Do you know how to assign addresses to sockets, including specifying wildcards, and making the addressing independent of the host byte order?

  2. What is the reason for the existence of the two socket address structures that we have studied, struct sockaddr and struct sockaddr_in?

  3. In the sockaddr structure, if an implementation were to change the structure definition to include an additional field: int junk, just before the sa_family field, then would our technique of passing a pointer to a sockaddr_in structure in the call to bind work? What if sockaddr_in too had this field before the sa_family field? What if sockaddr_in had this field, but after sa_family?

  4. What is a value-result argument, and why do we use a pointer in such arguments, instead of using an r-value?

  5. What is the difference between little-endian and big-endian formats? Which format is used in network byte order? What functions are used for conversion between host and network byte orders?

  6. Which functions can be used to convert between presentation and network IP addresses? What are some disadvantages of the inet_ntoa function?

  7. Learn about the use of memset, memcpy, memmove, memcmp, strcmp, and strcpy functions.

  8. Learn the use of the following functions: socket, connect, bind, listen, accept, getsockname, getpeername, wait, and waitpid.

  9. What is the backlog argument to listen, and which two queues are maintained for a listening socket?

  10. Does accept return a new file descriptor?

  11. When a process forks a child, are the sockets inherited by the child? What happens on an exec?

  12. If a process accepts a connection, forks a child, and then closes this socket, then is a FIN message immediately sent to the peer?

  13. What is a typical sequence of system calls on the client and on the server?

  14. A client typically does not bind to a port. Is this because it does not need a port? If not, then how is a port assigned to it?

  15. Learn about typical concurrent and iterative servers.

  16. Does a read get all the data sent by a write? If not, then how can you make sure that you get the entire data that was sent?

  17. Why were zombies created by our simple concurrent server example, and how can we prevent that? Why do we use waitpid instead of wait? What error checking do we need to make for some system calls, due to signal handling?

  18. What steps are involved when the client crashes, when the server crashes, and when the server host crashes?
I/O multiplexing (UNP chapter 6)

  1. Learn about the select system call, and details, such as: (i) When is select a slow system call? (ii) How do we specify a timeout. (iii) To what precision can we specify the timeout? (iv) Can the timeval structure be modified by the kernel, on calling select? (v) What does the book say about that and about the POSIX standard? (vi) What is the purpose of the 'maxf' argument in the multiplexed client? (vii) Why do we reset 'rset' before each call to select? (viii) When is a socket ready for reading? (ix) When is a listening socket ready for reading? (x) If a sockets receives an RST, then is it ready for reading or writing?

  2. What is a restricted pointer?

  3. What are the send and receive low water marks, and how do they influence the behavior of select?

  4. Learn how to implement a multiplexed server.
Pre-forked server (UNP chapter 27)

  1. Learn how to implement a pre-forked server.

  2. Learn about the intricacies of all children listening on the same socket.

  3. Why do we not handle SIGCHLD in the preforked server example that we discussed in class.

  4. Let us say a preforked server handles a maximum of N clients simultaneously. If more than N clients request service simultaneously, then what typically happens to the remaining clients?
Socket options (UNP chapter 7)

  1. Which function calls can be used to get and set socket options?

  2. What are three categories of socket options that we discussed in class?

  3. Do these functions enable you to get/set (i) the send buffer size, (ii) the receive buffer size, (iii) the send and receive low water marks, and (iv) the send and receive timeout?
UDP (UNP chapter 8)

  1. What are the typical sequences of system calls on a UDP client and server respectively?

  2. Learn about the use of sendto and recvfrom.

  3. What are the main differences between TCP and UDP?
Name and address conversions (UNP chapter 9)

  1. Learn about the use of the following functions: gethostbyname, gethostbyaddr, uname, gethostname, getservbyname, and getservbyport.

  2. Learn about the domain name system.

  3. What are some types of resource records that we discussed in class?
Be prepared for questions related to HW3 too.
Look at the example programs.
Review quiz questions, and other issues I mentioned in class as important.
Learn the syntax and the semantics of system calls used in the examples, and those mentioned in this review.

Last modified: 24 Oct 2002