All Packages Class Hierarchy This Package Previous Next Index
Class BaseLayer.BServerThread
Abstract.Connection
|
+----Abstract.ServerThread
|
+----BaseLayer.BServerThread
- public class BServerThread
- extends ServerThread
BServerThread is a thread which accept() connection from the other
agents. Then it will generate BRecvThread to listen and send message
For the protocol for connection, the Base layer assumes that when an agent
want to connect to other agent, it will initiate connection then wait "Connected"
message. If "Connected" message is received, it will imediately send its
name to the other agent. The reverse connection is the same.
Normally if the protocol and endWith character are not appropriate for your
system, you can subclass this class and override run() method.
BRecvThread is just a thread for send/receive messages.
- See Also:
- BRecvThread, ReceiverThread
-
BServerThread()
- Default constructor
-
BServerThread(Address, ConnectionTable, MessageBuffer, Security)
- Constructor using Address object
-
createReceiverThread(Socket)
- Create receiver thread using the socket, accepted by the 'run()' method.
-
endConn()
- Implements 'endConn()' method in Connection class.
-
run()
- Run method override
Waiting for accepting.
-
setDurationTime(int)
- Set duration time.
BServerThread
public BServerThread()
- Default constructor
BServerThread
public BServerThread(Address address,
ConnectionTable connections,
MessageBuffer mesg,
Security security) throws ConnectionException, UnknownHostException, IOException
- Constructor using Address object
- Parameters:
- address - Address object which contains port number
- connections - connection table
- mesg - the message queue
- security - Security object to be used to check connection protocol
setDurationTime
public void setDurationTime(int minutes)
- Set duration time. Simply assign.
- Parameters:
- minutes - Duration time will be set to all the generated Receiver Thread.
- Overrides:
- setDurationTime in class Connection
run
public void run()
- Run method override
Waiting for accepting. If accepted, it will create BRecvThread object
and send "Connected" message to the client. Then the client will send
its name. No other assumption on the protocol other than the above
description. You can override this method if you want more sophisticated
connection protocol.
ConnectionTable will be automatically updated.
The generated client receiver thread should be a subclass of BRecvThead.
It's default type is BRecvThread, but the extended type can be defined.
Do not forget to set endWith character if the messages are not
ended with '\004'
- Overrides:
- run in class ServerThread
createReceiverThread
protected synchronized void createReceiverThread(Socket socket)
- Create receiver thread using the socket, accepted by the 'run()' method.
- Parameters:
- socket - Socket, accepted by the ServerSocket
- Throws: ConnectionException
- if occurs
endConn
public synchronized void endConn()
- Implements 'endConn()' method in Connection class. Close the socket and stop
- Overrides:
- endConn in class Connection
All Packages Class Hierarchy This Package Previous Next Index