Week 12 - APUE 16 Socket Prog (includes TCP/IP)
[APUE16] Which of the following statements about socket programming is not correct?
A socket descriptor can be used with every function that accepts a file descriptor argument.
[APUE16] The single most important motive for the new IPv6 protocol is:
Address space expansion
[APUE16] In a layered protocol architecture (e.g., TCP/IP), a benefit and rationale for a module at one layer relying on another module at the layer below for some service is:
All of the above
[APUE16] Which of the following is an application layer program designed to run on top of TCP:
All of the above
[APUE16] Which of the following terms is used to denote units of data being transmitted:
All of the above
[APUE16] Which of the following statements about socket programming (address byte ordering) is not correct?
For a 32-bit integer with the value 0x04030201, the most significant byte is 0x01, and the least significant byte is 0x04 for little-endian byte order
[APUE16] Which of the following is part of the syntax of a protocol (e.g., TCP/IP):
Its packet format
[APUE16] Which of the following statements about socket is not correct?
Many of the functions with file descriptors (e.g., read or write) will not work with a socket descriptor.
[APUE16] Which of the following is common to both TCP and UDP:
Port-to-port communication
[APUE16] As a data unit moves up from one protocol layer to another (e.g., for TCP/IP), control headers are:
Removed
[APUE16] A protocol architecture (e.g., TCP/IP) performs a task by implementing it as:
Separate program modules, responsible for subtasks, that cooperate with each other
[APUE16] Which of the following statements about socket programming (out-of-band) is not correct?
TCP and UPD support out-of-band data.
[APUE16] Which of the following is an application layer protocol (e.g., in TCP/IP model).
Telnet
[APUE16] Which of the following is a transport layer protocol (TCP):
UDP
[APUE16] Which of the following statements about socket programming (nonblocking & asynchronous IO) is not correct?
When the socket is in blocking mode, the poll or select functions should be used to send or receive data.
[APUE16] Which of the following statements about socket programming (accept function) is not correct?
accept provides non-blocking socket.
[APUE16] Consider the following code segment to set socketfd to get connected to a server. The IP address and port # of the server are provided via the first and second arguments to run this program. Complete the following statement (underlined) to set server's port#. // socket int sockfd; struct sockaddr_in servaddr; char sendline[MAXLINE], recvline[MAXLINE]; sockfd = socket(AF_INET, SOCK_STREAM, 0); // to run: program 127.0.0.1 3000 struct sockaddr_in servaddr; memset(&servaddr, 0, sizeof(servaddr)); servaddr.sin_family = AF_INET; int port = atoi(argv[2]); servaddr.sin_port = ______(port);
htons
[APUE16] Consider the following code segment to set socketfd to get connected to a server. The IP address and port # of the server are provided via the first and second arguments to run this program. Complete the following statement (underlined) to set server's IP address. // socket int sockfd; struct sockaddr_in servaddr; char sendline[MAXLINE], recvline[MAXLINE]; sockfd = socket(AF_INET, SOCK_STREAM, 0); // to run: program 127.0.0.1 3000 struct sockaddr_in servaddr; memset(&servaddr, 0, sizeof(servaddr)); servaddr.sin_family = AF_INET; servaddr.sin_addr.s_addr = _______
inet_addr(argv[1])
[APUE16] ___ allows processes running on different computers (connected to a common network) to communicate with one another.
socket
[APUE16] Which of the following statements about socket programming (socket descriptor) is not correct?
to receive packets from multiple clients, one must have at least one socket connection per each client.