CSCE 3600 EXAM2QUESTIONS AND ANSWERS
* A socket system call returns _______for the created socket
A) A file descriptor
B) A process ID
C) A thread ID
D) A memory address - Answers - A) A file descriptor
#include <sys/types.h>
#include <sys/socket.h>
int accept(int sockfd, struct sockaddr* cliaddr,socklen_t * addrlen);
What is the purpose of the accept function in the given code snippet?
A) Initiates a connection on the socket
B) Closes the socket
C) Accepts a connection and returns a new file descriptor
D) Retrieves socket information - Answers - C) Accepts a connection and returns a new
file descriptor
#include <sys/types.h>
#include <sys/socket.h>
int accept(int sockfd, struct sockaddr* cliaddr,socklen_t * addrlen);
#include <sys/types.h>
#include <sys/socket.h>
int accept(int sockfd, struct sockaddr* cliaddr,socklen_t * addrlen);
What does the accept function return upon successfully accepting a connection?
A) -1
B) 0
C) A new file descriptor for the connection
D) The client's IP address - Answers - C) A new file descriptor for the connection
#include <sys/types.h>
#include <sys/socket.h>
int connect(int sockfd, const struct sockaddr* servaddr,socklen_t * addrlen);
What does the connect function in the given code snippet do?
A) Accepts incoming connections
B) Initiates a connection on the socket
C) Retrieves socket information
D) Closes the socket - Answers - B) Initiates a connection on the socket
#include <sys/types.h>
#include <sys/socket.h>
, int connect(int sockfd, const struct sockaddr* servaddr,socklen_t * addrlen);
What is the role of the servaddr parameter in the connect function?
A) It specifies the maximum number of connections
B) It contains the source IP address
C) It holds the server address information
D) It determines the communication protocol - Answers - C) It holds the server address
information
#include <sys/types.h>
#include <sys/socket.h>
int connect(int sockfd, const struct sockaddr* servaddr,socklen_t * addrlen);
What does the sockfd parameter represent in the connect function?
A) Server file descriptor
B) Socket file descriptor
C) Source IP address
D) Destination port number - Answers - B) Socket file descriptor
#include <sys/types.h>
#include <sys/socket.h>
int connect(int sockfd, const struct sockaddr* servaddr,socklen_t * addrlen);
What does the connect function return upon successful connection?
A) 1
B) -1
C) 0
D) Socket file descriptor - Answers - C) 0
* A pthread_create function returns_______ for the newly created thread.
A) A file descriptor
B) A process ID
C) A thread ID
D) A memory address - Answers - C) A thread ID
* A fork() function returns _______ for the newly created process.
A) A file descriptor
B) A process ID
C) A thread ID
D) 0 - Answers - B) A process ID
* Which of the following statements is true regarding processes and their requirements?
A) A process is the same as an executing program.
B) A process doesn't require any resources to accomplish its task.
C) A process requires only CPU time to accomplish its task.
* A socket system call returns _______for the created socket
A) A file descriptor
B) A process ID
C) A thread ID
D) A memory address - Answers - A) A file descriptor
#include <sys/types.h>
#include <sys/socket.h>
int accept(int sockfd, struct sockaddr* cliaddr,socklen_t * addrlen);
What is the purpose of the accept function in the given code snippet?
A) Initiates a connection on the socket
B) Closes the socket
C) Accepts a connection and returns a new file descriptor
D) Retrieves socket information - Answers - C) Accepts a connection and returns a new
file descriptor
#include <sys/types.h>
#include <sys/socket.h>
int accept(int sockfd, struct sockaddr* cliaddr,socklen_t * addrlen);
#include <sys/types.h>
#include <sys/socket.h>
int accept(int sockfd, struct sockaddr* cliaddr,socklen_t * addrlen);
What does the accept function return upon successfully accepting a connection?
A) -1
B) 0
C) A new file descriptor for the connection
D) The client's IP address - Answers - C) A new file descriptor for the connection
#include <sys/types.h>
#include <sys/socket.h>
int connect(int sockfd, const struct sockaddr* servaddr,socklen_t * addrlen);
What does the connect function in the given code snippet do?
A) Accepts incoming connections
B) Initiates a connection on the socket
C) Retrieves socket information
D) Closes the socket - Answers - B) Initiates a connection on the socket
#include <sys/types.h>
#include <sys/socket.h>
, int connect(int sockfd, const struct sockaddr* servaddr,socklen_t * addrlen);
What is the role of the servaddr parameter in the connect function?
A) It specifies the maximum number of connections
B) It contains the source IP address
C) It holds the server address information
D) It determines the communication protocol - Answers - C) It holds the server address
information
#include <sys/types.h>
#include <sys/socket.h>
int connect(int sockfd, const struct sockaddr* servaddr,socklen_t * addrlen);
What does the sockfd parameter represent in the connect function?
A) Server file descriptor
B) Socket file descriptor
C) Source IP address
D) Destination port number - Answers - B) Socket file descriptor
#include <sys/types.h>
#include <sys/socket.h>
int connect(int sockfd, const struct sockaddr* servaddr,socklen_t * addrlen);
What does the connect function return upon successful connection?
A) 1
B) -1
C) 0
D) Socket file descriptor - Answers - C) 0
* A pthread_create function returns_______ for the newly created thread.
A) A file descriptor
B) A process ID
C) A thread ID
D) A memory address - Answers - C) A thread ID
* A fork() function returns _______ for the newly created process.
A) A file descriptor
B) A process ID
C) A thread ID
D) 0 - Answers - B) A process ID
* Which of the following statements is true regarding processes and their requirements?
A) A process is the same as an executing program.
B) A process doesn't require any resources to accomplish its task.
C) A process requires only CPU time to accomplish its task.