game.net
Class Server_network_layer

java.lang.Object
  extended by game.net.Server_network_layer
All Implemented Interfaces:
Server_network_interface

public class Server_network_layer
extends java.lang.Object
implements Server_network_interface

This class is used by the server to get and send from the network. The server should be started first. Up to two client connections are accepted. These are referred to as west and east.


Field Summary
static int EAST
          Deprecated. Use a_soccertools.interfaces.Server_network_interface.EAST instead.
static int WEST
          Deprecated. Use a_soccertools.interfaces.Server_network_interface.WEST instead.
 
Constructor Summary
Server_network_layer()
          Construct a network layer object.
 
Method Summary
 int get_line(int mask, java.lang.StringBuffer str_buf)
          Attempt to read one line from a subset of the clients.
 void init(int server_port)
          Initialize the network layer.
 void send_line(java.lang.String line, int which)
          Sends a line to one client.
 void shutdown()
          Finish everything up
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WEST

public static final int WEST
Deprecated. Use a_soccertools.interfaces.Server_network_interface.WEST instead.
See Also:
Server_network_interface, Constant Field Values

EAST

public static final int EAST
Deprecated. Use a_soccertools.interfaces.Server_network_interface.EAST instead.
See Also:
Server_network_interface, Constant Field Values
Constructor Detail

Server_network_layer

public Server_network_layer()
Construct a network layer object.

Method Detail

init

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

Parameters:
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,
                      int which)
               throws java.io.IOException
Sends a line to one client.

Specified by:
send_line in interface Server_network_interface
Parameters:
line - this should end in a newline.
which - this should be server_network_layer.WEST or server_network_layer.EAST
Throws:
java.io.IOException - if the line can not be sent.
See Also:
Server_network_interface

get_line

public int get_line(int mask,
                    java.lang.StringBuffer str_buf)
             throws java.io.IOException
Attempt to read one line from a subset of the clients.

Specified by:
get_line in interface Server_network_interface
Parameters:
mask - indicates where the line should come from. It may be, WEST, EAST, or WEST|EAST to indicate either is ok.
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:
server_network_layer.WEST if the line was gotten from the west client, server_network_layer.EAST if a line was gotten from the east client, and 0 if no line was read.
Throws:
java.io.IOException - if trouble reading the line.
See Also:
Server_network_interface

shutdown

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

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