Chapter 33 Networking
Section 33.2 Client/Server Computing
1. When creating a server on a port that is already in use, .
a. java.net.BindException occurs
b. the server is created with no problems
c. the server is blocked until the port is available
d. the server encounters a fatal error and must be terminated
#
2. When creating a client on a server port that is already in use, .
a. the client can connect to the server regardless of whether the port is in use
b. java.net.BindException occurs
c. the client is blocked until the port is available
d. the client encounters a fatal error and must be terminated
#
3. The server listens for a connection request from a client using the following statement:
a. Socket s = new Socket(ServerName, port);
b. Socket s = serverSocket.accept()
c. Socket s = serverSocket.getSocket()
d. Socket s = new Socket(ServerName);
#
4. The client requests a connection to a server using the following statement:
a. Socket s = new Socket(ServerName, port);
b. Socket s = serverSocket.accept();
c. Socket s = serverSocket.getSocket();
d. Socket s = new Socket(ServerName);
#
5. When a client requests connection to a server that has not yet started, .
a. java.net.BindException occurs
b. java.net.ConnectionException occurs
c. the client is blocked until the server is started
d. the client encounters a fatal error and must be terminated
#
6. To connect to a server running on the same machine with the client, which of the following can be used for the
hostname?
a. “localhost”
b. “127.0.0.1”
c. InetAddress.getLocalHost(),
d. “127.127.127.1”.
#