All Packages Class Hierarchy This Package Previous Next Index
Class ProtocolLayer.ConnectorThread
ProtocolLayer.ConnectorThread
- public class ConnectorThread
Socket connector between an applet and server(SMTP,POP3,FTP,HTTP,etc.). Since an applet can
not create socket other than it spawned from, router will take a role as proxy to
connect the applet and servers. Router will create connector which connects the applet and
servers. Connector will have two sockets, one for a server and one for an applet. Data input
from any of two socket will be redirected to other side. Initially, a server address(host,port)
will be passed to the constructor. After Connector connect to the server, it will create a
server socket for the applet. The server socket port number will be passed to the applet and the applet will
connect to the server socket. The socket port number will be passed as high level KQML message
with performative 'port-info'.
-
_client
-
-
_clientQueue
- Message buffer for a client applet
-
_clientServerSocket
- Server socket, created for an applet connection for data transfer
-
_endWith
- Message endWith character.
-
_maxWaitTime
- Maximum time set in minutes
-
_server
- Receiver thread for an internet server such as SMTP, FTP
-
_serverQueue
- Message buffer for a server thread
-
_timer
- Timer to check time out.
-
ConnectorThread()
- Default constructor
-
ConnectorThread(Address, int, int)
- Constructor with internet service server address, priority and maximum idle time.
-
ConnectorThread(Socket, int, int)
- Constructor with internet service server address, priority and maximum idle time.
-
disconnectCon()
- Disconnect connection but does not kill timer.
-
endConn()
- Kill timer and disconnect.
-
getClientServerSocketNumber()
- Accessor to get machine generated client ServerSocket number.
-
init(Socket, int, int)
- Initialize data members, Server thread will be created and ServerSocket for an applet
will be created.
-
isConnected()
- Accessor to see whether client applet is connected or not
-
resetTimer()
- Reset timer.
-
run()
- Default behavior is to read from any of message queues - server side and client side.
-
setEndWith(char)
- Set endWith character if different from '\n'
-
stopTimer()
- Stop timer thread
_client
protected BRecvThread _client
_clientQueue
protected BMessageBuffer _clientQueue
- Message buffer for a client applet
_server
protected BRecvThread _server
- Receiver thread for an internet server such as SMTP, FTP
_serverQueue
protected BMessageBuffer _serverQueue
- Message buffer for a server thread
_clientServerSocket
protected ServerSocket _clientServerSocket
- Server socket, created for an applet connection for data transfer
_maxWaitTime
protected int _maxWaitTime
- Maximum time set in minutes
_endWith
protected char _endWith
- Message endWith character. Default is '\n'. You need to use setEndWith(char) method
if messages are not ended with '\n'.
_timer
protected ConnectorTimerThread _timer
- Timer to check time out. If time out, the thread will stop this thread and timer itself
will stop. If data transfer is successful, timer will be stop by this thread.
ConnectorThread
public ConnectorThread()
- Default constructor
ConnectorThread
public ConnectorThread(Address serverAddress,
int priority,
int connectionWaitTime) throws ConnectionException
- Constructor with internet service server address, priority and maximum idle time.
Router will try to connect to given service address.
- Parameters:
- serverAddress - Internet service server address.
- priority - Thread priority
- connectionWaitTime - Maximum idle time.
- Throws: ConnectionException
- If server connection is failed, or
fails to create ServerSocket for an applet.
ConnectorThread
public ConnectorThread(Socket toSocket,
int priority,
int connectionWaitTime) throws ConnectionException
- Constructor with internet service server address, priority and maximum idle time.
Router will try to connect to given service address.
- Parameters:
- toSocket - Internet service server socket.
- priority - Thread priority
- connectionWaitTime - Maximum idle time.
- Throws: ConnectionException
- If server connection is failed, or
fails to create ServerSocket for an applet.
init
protected void init(Socket socket,
int priority,
int connectionTime) throws ConnectionException
- Initialize data members, Server thread will be created and ServerSocket for an applet
will be created. Client thread for an applet will not be initialized here. Initialization
of client thread will be performed at run time, after accept a connection from the applet.
- Parameters:
- socket - Socket for internet service server
- priority - Priority for this thread
- connectionTime - Max. idle time
isConnected
public boolean isConnected()
- Accessor to see whether client applet is connected or not
- Returns:
- true if connected
setEndWith
public void setEndWith(char endwith)
- Set endWith character if different from '\n'
- Parameters:
- endWith - End with character
getClientServerSocketNumber
public int getClientServerSocketNumber()
- Accessor to get machine generated client ServerSocket number.
- Returns:
- ServerSocket number for the applet to connect
run
public void run()
- Default behavior is to read from any of message queues - server side and client side.
If there's a message, send it to
counter part(e.g. a message from server side will send to applet , vice versa.)
Default behavior may not be appropriate for FTP, HTTP, POP3, etc. For each protocol,
Connector will need to be extended. Timer will be set for waiting connection from an
applet. If time limit is over, thread will close all the connection and stop.
disconnectCon
public void disconnectCon()
- Disconnect connection but does not kill timer. This method should be invoked only from
ConnectorTimer.
endConn
protected void endConn()
- Kill timer and disconnect.
stopTimer
protected void stopTimer()
- Stop timer thread
resetTimer
protected void resetTimer()
- Reset timer. If timer is not created yet, created one.
All Packages Class Hierarchy This Package Previous Next Index