CSC 145/290: Assignment 5 Due Thursday 10/25/2001 This assignment asks you to devise and conduct experiements to better understand the behavior of sockets and associated file descriptors. 1. When fork is called, the child process gets a copy of the file descriptors. Both processes must close the descriptor before it's truely closed. The question is, let's say the descriptor is for a socket, and something is written to the socket (from a possibly remote host). If one process (say parent), reads the info from the descriptor, can it still be read by the child process? That is, if the data is consumed by one process, will it still be available for the other process. 1b. What if the child process used "dup" on the descriptor - will it then get a copy of all the data sent to it? 1c. What if FILE* streams are created by both parent and child process. will there be two copies of the data then. 1d. What if both parent and child trys to WRITE to the same file descriptor (same socket). What will the other side receive? 2. (OPTIONAL) The TCP protocol terminates with an elaborate handshake to make sure that unacknowledged packets from a previous connection aren't mistaken as packets for a new connection. When you close a socket, and use netstat to see connections, you'll see the connections going to the 'TIME_WAIT'and 'CLOSE_WAIT' states. This behavior can be altered by using setsockopt on the SO_LINGER option. (read chapter 7 of text). Devise an experiment to show how if the temination handshake is avoided, strange behavior can result upon reconnection.