All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class Abstract.ServerThread

Abstract.Connection
   |
   +----Abstract.ServerThread

public abstract class ServerThread
extends Connection
ServerThread is a thread which accept() connection from the other agents. Then it will generate ReceiverThread to receive and send message. If the protocol and endWith character are not appropriate for your system, you can use setEndWitn(char) method to define end with charecter. ReceiverThread is just a thread for send/receive messages. No high level protocol is assumed on the ReceiverThread.

See Also:
BRecvThread

Variable Index

 o _listenSocket
ServerSocket object
 o _queue
Message Queue normally passed from AgentAction object

Constructor Index

 o ServerThread()
Default constructor
 o ServerThread(Address, ConnectionTable, MessageBuffer, Security)
Constructor using Address, ConnectionTable,MessageBuffer and Security objects.

Method Index

 o getMessageQueue()
Get message queue
 o getServerSocket()
Get ServerSocket
 o run()
Listening and waiting for connection.
 o setMessageQueue(MessageBuffer)
Set message queue
 o setServerSocket(ServerSocket)
Set ServerSocket for the ServerThread

Variables

 o _listenSocket
 protected ServerSocket _listenSocket
ServerSocket object

 o _queue
 protected MessageBuffer _queue
Message Queue normally passed from AgentAction object

See Also:
MessageBuffer

Constructors

 o ServerThread
 public ServerThread()
Default constructor

 o ServerThread
 public ServerThread(Address address,
                     ConnectionTable connections,
                     MessageBuffer mesg,
                     Security security) throws ConnectionException, UnknownHostException, IOException
Constructor using Address, ConnectionTable,MessageBuffer and Security objects.

Parameters:
address - My address object which contains port number
connections - connection table
mesg - the message queue
security - Security object which will be passed to the ReceiverThread
Throws: ConnectionException,
UnknownHostException, IOException

Methods

 o getMessageQueue
 public MessageBuffer getMessageQueue()
Get message queue

Returns:
MessageBuffer
 o setMessageQueue
 public void setMessageQueue(MessageBuffer queue)
Set message queue

Parameters:
queue - MessageBuffer
 o setServerSocket
 public void setServerSocket(ServerSocket s)
Set ServerSocket for the ServerThread

Parameters:
s - ServerSocket,opened for the ServerThread
 o getServerSocket
 public ServerSocket getServerSocket()
Get ServerSocket

Returns:
ServerSocket, which is listening
 o run
 public void run()
Listening and waiting for connection. If accepted, it will create ReceiverThread object. ConnectionTable will be automatically updated by Security object The generated client receiver thread should be a subclass of ReceiverThread. Do not forget to set endWith character if the messages are not ended with '\004'


All Packages  Class Hierarchy  This Package  Previous  Next  Index