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)
-
- What are some protocols that we have discussed in class?
- Which version of IP have we used in our examples?
- What are the important differences between TCP and UDP?
- Do you know the TCP connection establishment and termination sequences?
- Do you know the relationship between socket related system
calls, and corresponding actions that take place in the TCP layer in
the kernel.
- Do you know what information uniquely identifies a TCP connection?
- 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)
-
- Do you know how to assign addresses to sockets, including
specifying wildcards, and making the addressing independent of the
host byte order?
- What is the reason for the existence of the two socket address
structures that we have studied,
struct sockaddr
and struct sockaddr_in
?
- 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
?
- What is a value-result argument, and why do we use a pointer
in such arguments, instead of using an r-value?
- 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?
- Which functions can be used to convert between presentation and
network IP addresses? What are some disadvantages of the
inet_ntoa
function?
- Learn about the use of
memset, memcpy, memmove, memcmp,
strcmp
, and strcpy
functions.
- Learn the use of the following functions:
socket, connect,
bind, listen, accept, getsockname, getpeername, wait,
and waitpid
.
- What is the backlog argument to listen, and which two queues
are maintained for a listening socket?
- Does accept return a new file descriptor?
- When a process forks a child, are the sockets inherited by the
child? What happens on an exec?
- If a process accepts a connection, forks a child, and then
closes this socket, then is a
FIN
message immediately sent to the
peer?
- What is a typical sequence of system calls on the client and
on the server?
- 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?
- Learn about typical concurrent and iterative servers.
- 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?
- 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?
- What steps are involved when the client crashes, when the
server crashes, and when the server host crashes?
- I/O multiplexing (UNP chapter 6)
-
- 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?
- What is a
restrict
ed pointer?
- What are the send and receive low water marks, and how do they
influence the behavior of select?
- Learn how to implement a multiplexed server.
- Pre-forked server (UNP chapter 27)
-
- Learn how to implement a pre-forked server.
- Learn about the intricacies of all children listening on the
same socket.
- Why do we not handle
SIGCHLD
in the preforked server example
that we discussed in class.
- 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)
-
- Which function calls can be used to get and set socket
options?
- What are three categories of socket options that we discussed
in class?
- 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)
-
- What are the typical sequences of system calls on a UDP client
and server respectively?
- Learn about the use of
sendto
and recvfrom
.
- What are the main differences between TCP and UDP?
- Name and address conversions (UNP chapter 9)
-
- Learn about the use of the following functions:
gethostbyname, gethostbyaddr, uname, gethostname,
getservbyname,
and getservbyport
.
- Learn about the domain name system.
- 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