APUE16
[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 is not correct? For socket descriptor, one gets a file descriptor that can be used for I/O. For socket descriptor, using the file descriptor, you call close to relinquish access to the file or socket and free up the file descriptor for reuse. A socket descriptor is actually a file descriptor A socket descriptor can be used with every function that accepts a file descriptor argument.
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: The lower-layer module can extend its service to multiple modules at the higher layer If called for, transparent to the higher-layer module, the lower-layer module can be replaced The higher-layer module can dispense with coding the logic for that service All of the above
All of the above
[APUE16] Which of the following is an application layer program designed to run on top of TCP: TELNET File Transfer Protocol (FTP) Simple Mail Transfer Program (SMTP) All of the above
All of the above
[APUE16] Which of the following terms is used to denote units of data being transmitted: Segment Datagram Frame All of the above
All of the above
[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 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 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] 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] Which of the following statements about socket programming (address byte ordering) is not correct? If the processor architecture supports big-endian byte order, then the highest byte address occurs in the least significant byte (LSB). If the processor architecture supports little-endian byte order, then the highest byte address occurs in the most significant byte (MSB). Regardless of the byte ordering, the most significant byte (MSB) is always on the left, and the least significant byte is always on the right. 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. The TCP/IP protocol suite uses big-endian byte order. The byte ordering becomes visible to applications when they exchange formatted data.
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 statements about socket is not correct? Socket is an abstraction of a communication endpoint. Applications use socket descriptors to access sockets. Socket descriptors are implemented as file descriptors in the UNIX System. Many of the functions with file descriptors (e.g., read or write) will not work with a socket descriptor.
Many of the functions with file descriptors (e.g., read or write) will not work with a socket descriptor.
APUE16] Which of the following statements about socket programming (out-of-band) is not correct? Out-of-band data is an optional feature supported by some communication protocols Out-of-band data allows higher-priority delivery of data than normal. Out-of-band data is sent ahead of any data that is already queued for transmission. TCP and UPD support out-of-band data. TCP refers to out-of-band data as ''urgent'' data.
TCP and UPD support out-of-band data.
[APUE16] Which of the following statements about socket programming (nonblocking & asynchronous IO) is not correct? Normally, the recv functions will block when no data is immediately available. Normally, the send functions will block when there is not enough room in the socket's output queue to send the message. The blocking behavior of the send and recv functions can be changed by setting socket option. When the socket is in nonblocking mode, the send and recv functions will fail instead of blocking When the socket is in blocking mode, the poll or select functions should be used to send or receive data.
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. The file descriptor returned by accept is a socket descriptor that is connected to the client that called connect. The new socket descriptor by accept has the same socket type and address family as the original socket (sockfd). The original socket passed to accept is not associated with the connection, but instead remains available to receive additional connect requests. On return, accept will fill in the client's address in the buffer and update the integer field (len) to reflect the size of the address. If no connect requests are pending, accept will block until one arrives.
accept provides non-blocking socket.
[APUE16] Which of the following statements about socket programming (socket descriptor) is not correct? a socket endpoint is represented as a file descriptor. one can use read and write to communicate with a socket, as long as it is connected. using read and write with socket descriptors is significant for one can pass socket descriptors to functions designed to work with local files. the socket descriptors can be passed to child processes that execute programs that know nothing about sockets. Although we can exchange data using read and write, that is about all we can do with these two functions. to receive packets from multiple clients, one must have at least one socket connection per each client.
to receive packets from multiple clients, one must have at least one socket connection per each client.