game.net
Class Client_network_layer

java.lang.Object
  extended by game.net.Client_network_layer
All Implemented Interfaces:
Client_network_interface

public class Client_network_layer
extends java.lang.Object
implements Client_network_interface

This class is used by the client to get lines from the network.


Constructor Summary
Client_network_layer()
          Construct a network layer object.
 
Method Summary
 boolean get_line(java.lang.StringBuffer str_buf)
          Attempt to read one line from the server.
 void init(java.lang.String server_host_number_or_name, int server_port)
          Initialize the network layer.
 void send_line(java.lang.String line)
          Send one line to the server.
 void shutdown()
          Finish everything up
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Client_network_layer

public Client_network_layer()
Construct a network layer object.

Method Detail

init

public void init(java.lang.String server_host_number_or_name,
                 int server_port)
          throws java.net.UnknownHostException,
                 java.io.IOException
Initialize the network layer.

Parameters:
server_host_number_or_name - This can be either of the form 134.153.12.70 or of the form peta.engr.mun.ca.
server_port - this is the "well known port number" for the server.
Throws:
java.net.UnknownHostException - if the server host can not be found.
java.io.IOException - if communication with the server can not be initialized.

send_line

public void send_line(java.lang.String line)
               throws java.io.IOException
Send one line to the server.

Specified by:
send_line in interface Client_network_interface
Parameters:
line - This should end in a newline.
Throws:
java.io.IOException - if the line can not be sent.
See Also:
Client_network_interface

get_line

public boolean get_line(java.lang.StringBuffer str_buf)
                 throws java.io.IOException
Attempt to read one line from the server.

Specified by:
get_line in interface Client_network_interface
Parameters:
str_buf - a string buffer onto which the line will be appended if a line is read. Typically you would pass a new string buffer.
Returns:
true if the line was gotten and false otherwise.
Throws:
java.io.IOException - if there was trouble reading the line.
See Also:
Client_network_interface

shutdown

public void shutdown()
              throws java.io.IOException
Finish everything up

Throws:
java.io.IOException - if any trouble ;