References


Self-Test Questions

1. 

List and describe each step of the socket-based client-server connection scenario.

image from book

2. 

What class from the java.net package is used to listen for incoming socket connections?

image from book

3. 

Describe in general terms what is required to create a multi-threaded server application.

image from book

4. 

List and describe the steps involved with creating an RMI-based server application.

image from book

5. 

What must an RMI-based client do before it can use the services of a remote object?

 - get a reference to the service with the naming.lookup() method.

6. 

What must be established prior to conducting effective socket-based client-server communications?

 - appropriate inter-application protocols

7. 

What interface does a remote object’s interface extend?

image from book

8. 

What class from the java.rmi.server package does a remote object extend? What interface does it implement?

image from book

9. 

What method found in the ServerSocket class blocks until an incoming client connection is detected?

 - serversocket.accept()

10. 

What is the default RMI registry port number?

image from book

11. 

If a UTF string is written to an output stream using the DataOutputStream.writeUTF() method, what method of what class must be called to read the string on the receiving end?

 - datainputstream.readutf()

12. 

What methods of the java.net.Socket class are used to retrieve the InputStream and OutputStream objects from the socket?

 - getinputstream(), getoutputstream()

Answers

1. 

- a Socket object is used to connect to a ServerSocket object which is listening on a specified host and port. When the ServerSocket object detects an incoming client connection the accept() method will return a Socket object that can be used to communicate between server and client applications.

2. 

- ServerSocket

3. 

- A separate class that extends Thread or implements Runnable must be created to handle inter-application communication via the Socket object between the client and server applications.

4. 

  • Step 1: Define A Remote Interface

  • Step 2: Define A Remote Interface Implementation

  • Step 3: Compile The Remote Interface & Remote Interface Implementation Source Files

  • Step 4: Use The rmic Tool To Generate Stub Class

  • Step 5: Create Server Application

  • Step 6: Create Client Application

  • Step 7: Start The RMI Registry

  • Step 8: Run The Server Application

  • Step 9: Run The Client Application

5. 

- Get a reference to the service with the Naming.lookup() method.

6. 

- Appropriate inter-application protocols

7. 

- java.rmi.Remote

8. 

- UnicastRemoteObject; It implements the user-defined interface created by extending the java.rmi.Remote interface.

9. 

- ServerSocket.accept()

10. 

- 1099

11. 

- DataInputStream.readUTF()

12. 

- getInputStream(), getOutputStream()




Java For Artists(c) The Art, Philosophy, and Science of Object-Oriented Programming
Java For Artists: The Art, Philosophy, And Science Of Object-Oriented Programming
ISBN: 1932504052
EAN: 2147483647
Year: 2007
Pages: 452

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net