next up previous contents
Next: The Client Up: Server Classes Previous: Calculating the minimum spanning   Contents

ServerConnection

ServerConnection encapsulates all the functions that are common to both Server-to-Client connections(the StoCconnection subclass) and Server-to-Server connections(the StoSconnection subclass).

To make it easy for the server to know which subclass of ServerConnection to create on detecting an incoming connection, incoming client and server connections are handled on separate ports. The server reads a ``base_port'' from the configuration file and then checks that base_port+1 and base_port+2 are available, otherwise it increments base_port by 3 and tries again. The base_port then listens for incoming client connections, base_port+1 listens for incoming server connections and the TCPechod is run on base_port+2.3.3

In StoSconnection, one of the problems encountered when writing the run() method was knowing how to differentiate between exiting from run() because the connection had died and when the other server had simply asked this server to disconnect (e.g. because it had reached a maximum number of connections). The solution was to make run() return a boolean value: true if it exited because of a disconnect message, false if the connection died in some way, indicating if the server should issue a deleteServer message. StoCconnection does not have this problem because no action is taken on a disconnect (the user's status cannot be updated to ``offline'' without a signature!).


next up previous contents
Next: The Client Up: Server Classes Previous: Calculating the minimum spanning   Contents
Nathan Dimmock 2001-06-20