All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class ProtocolLayer.FTPConnectorThread

ProtocolLayer.ConnectorThread
   |
   +----ProtocolLayer.FTPConnectorThread

public class FTPConnectorThread
extends ConnectorThread
ConnectorThread which takes a role to make a server socket for applet data transfer. When an applet wants data transfer using FTP protocol, FTPConnectorThread will be created to connect the applet and a FTP server. This connector will create one ServerSocket for each FTP 'PORT' operation. From the agent perspective, it will use pre-existing FTP.


Constructor Index

 o FTPConnectorThread(Address, int, int)
Constructor using FTP server address.
 o FTPConnectorThread(Socket, int, int)
Constructor with internet service server address, priority and maximum idle time.

Method Index

 o closePortConnector()
Close port connector
 o createFTPPortThread()
Create FTP PORT thread to process data FTPPortThread will create two server socket, one for server side and one for applet side.
 o dataTransfer(boolean)
Data transfer transaction.
 o disconnectCon()
Will be invoked by timer, if time out reached.
 o run()
Starts to accept socket connection from an applet.
 o sendMessageToClient(String)
Send a message to applet side
 o sendMessageToServer(String)
Send a message to server side

Constructors

 o FTPConnectorThread
 public FTPConnectorThread(Address serverAddress,
                           int priority,
                           int connectionWaitTime) throws ConnectionException
Constructor using FTP server address.

Parameters:
serverAddress - FTP server address
priority - Thread priority
connectionWaitTime - Maximum idle time
 o FTPConnectorThread
 public FTPConnectorThread(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.

Methods

 o run
 public void run()
Starts to accept socket connection from an applet. Afer accepting the connection, Receiver thread to receive messages from the applet will be created and started. ServerSocket opened for accepting the connection will be closed. Then, receiving/sending messages from both sides will be performed until "QUIT" message is received from the applet side. If the applet has no chance to send 'QUIT' message to router, this thread will stop after maximum idle time.

Overrides:
run in class ConnectorThread
 o dataTransfer
 protected void dataTransfer(boolean getOrPut) throws ConnectionException
Data transfer transaction. Currently synchronous transfer is used.

Parameters:
getOrPut - Get or Put operation. PUT is true.
 o closePortConnector
 protected void closePortConnector()
Close port connector

 o sendMessageToServer
 protected void sendMessageToServer(String msg) throws ConnectionException
Send a message to server side

Parameters:
msg - FTP message
Throws: ConnctionException
if writing fails
 o sendMessageToClient
 protected void sendMessageToClient(String msg) throws ConnectionException
Send a message to applet side

Parameters:
msg - FTP message
Throws: ConnctionException
if writing fails
 o createFTPPortThread
 protected void createFTPPortThread() throws ConnectionException
Create FTP PORT thread to process data FTPPortThread will create two server socket, one for server side and one for applet side. Port number will be passed according to protocol format.

 o disconnectCon
 public void disconnectCon()
Will be invoked by timer, if time out reached. Stop FTPConPortThread if still alive

Overrides:
disconnectCon in class ConnectorThread

All Packages  Class Hierarchy  This Package  Previous  Next  Index