Class cam.netapp.NetworkConnection
java.lang.Object
|
+----cam.netapp.NetworkConnection
- public class NetworkConnection
- extends Object
An instance of this class is typically associated with the "front end" of a distributed application.
The NetworkConnection class performs two important functions
- It instantiates a remote class and sets up stream communications with that instance. It does this by communicating
with a cam.netapp.ServerManager executing on the remote machine.
- It provides run-time control of the remote class instance.
The "back-end" does not require an instance of this class (it is only required to implement the Runnable
interface and the SetStreams interface).
The remote class usually resides on another machine, but for development purposes, one can use a NetworkConnection
to connect to a class on a local machine.
In order to establish a remote class instance on another machine, an instance of the ServerManager class must
be executing on that machine.
- Version:
- 9/18/98
- Author:
- Chris Anderson and Dan Delsol (C) UCLA 1997-98
-
NetworkConnection()
- Standard constructor.
-
NetworkConnection(Socket[])
- Creates a network connection using the sockets passed in sArray for
communication.
-
connectRemoteApplication(String)
- Creates a connection to a local class appName.
-
connectRemoteApplication(String, int, String)
- Creates a connection to the application appName at (address,port).
-
connectRemoteApplication(String, int, String, int)
- Creates a connection to the application appName at (address,port) with auxConnections
auxillary socket connections.
-
createControlStreams()
- Create streams to communicate with the control thread using sockets[1]
-
disconnectRemoteApplication()
- Stops the remote class thread and closes connections to the remote class.
-
finalize()
- Stops the remote class thread.
-
getAuxSocket(int)
- Returns the the kth auxillary socket associated with the current connection.
-
getControlInputStream()
- Returns the InputStream associated with the control Socket connection.
-
getControlOutputStream()
- Returns the OutputStream associated with the control socket
connection.
-
getControlSocket()
- Returns the control socket connected to the remote class's control.
-
getInputStream()
- Returns the InputStream associated with the socket
connection to the remote instance.
-
getOutputStream()
- Returns the OutputStream associated with the socket
connection to the remote instance.
-
getRemoteApplicationStatus()
- Returns the status of the remote class.
-
getSocket()
- Returns the primary socket connected to the remote class.
-
pauseRemoteApplication()
- Pauses the remote class thread.
-
resumeRemoteApplication()
- Resumes the remote class thread.
-
setVerboseFlag(boolean)
- If set true diagnostic messages are printed to System.out.
-
startRemoteApplication()
- Creates a thread for the remote class and invokes the run() method of the remote
class.
-
stopRemoteApplication()
- Stops the remote class thread.
NetworkConnection
public NetworkConnection()
- Standard constructor.
NetworkConnection
public NetworkConnection(Socket sArray[])
- Creates a network connection using the sockets passed in sArray for
communication. The control streams are NOT created with this construction.
Control commands (startRemoteApplication(), stopRemoteApplication()... have
no effect.
If the control streams are desired, then the createControlStreams() method
should be called after the constructor. Use of the control streams presumes
that there is a remote ControlThread instance connected to sockets[1].
connectRemoteApplication
public void connectRemoteApplication(String address,
int portnum,
String appName) throws NetAppException
- Creates a connection to the application appName at (address,port).
- Parameters:
- address - Address of remote machine upon which a ServerManager is executing
- portnum - Port where the remote machine that the ServerManager is listening. (Default = 6789).
- appName - Name of the class on the remote machine
- Throws: NetAppException
- if the connection can not be completed.
connectRemoteApplication
public void connectRemoteApplication(String nameApp) throws NetAppException
- Creates a connection to a local class appName. An appName instance is loaded and
a cross-stream connection is made to it. A separate thread is then created for
the instance and it's run() method is invoked.
- Parameters:
- appName - Name of the class on the remote machine
- Throws: NetAppException
- if the connection can not be completed.
connectRemoteApplication
public void connectRemoteApplication(String address,
int portnum,
String appName,
int auxConnections) throws NetAppException
- Creates a connection to the application appName at (address,port) with auxConnections
auxillary socket connections. Typically auxConnections = 1 for use in creating
NetworkConnection callbacks from the application to the client.
- Parameters:
- address - Address of remote machine upon which a ServerManager is executing
- portnum - Port where the remote machine that the ServerManager is listening. (Default = 6789).
- appName - Name of the class on the remote machine
- auxConnections - The number of auxillary connections to the remote class
(typically 0, unless one is implementing callbacks).
- Throws: NetAppException
- if the connection can not be completed.
disconnectRemoteApplication
public void disconnectRemoteApplication()
- Stops the remote class thread and closes connections to the remote class.
startRemoteApplication
public void startRemoteApplication()
- Creates a thread for the remote class and invokes the run() method of the remote
class.
stopRemoteApplication
public void stopRemoteApplication()
- Stops the remote class thread.
pauseRemoteApplication
public void pauseRemoteApplication()
- Pauses the remote class thread.
resumeRemoteApplication
public void resumeRemoteApplication()
- Resumes the remote class thread.
getRemoteApplicationStatus
public String getRemoteApplicationStatus()
- Returns the status of the remote class.
getSocket
public Socket getSocket()
- Returns the primary socket connected to the remote class.
getControlSocket
public Socket getControlSocket()
- Returns the control socket connected to the remote class's control.
getAuxSocket
public Socket getAuxSocket(int k)
- Returns the the kth auxillary socket associated with the current connection.
- Parameters:
- k - The index of the socket.
getOutputStream
public OutputStream getOutputStream()
- Returns the OutputStream associated with the socket
connection to the remote instance. One writes to this stream to send
data to the remote class.
getControlOutputStream
public OutputStream getControlOutputStream()
- Returns the OutputStream associated with the control socket
connection. One writes to this stream to send
data to the remote class's control.
getInputStream
public InputStream getInputStream()
- Returns the InputStream associated with the socket
connection to the remote instance. One reads from this stream to obtain
data from the remote class.
getControlInputStream
public InputStream getControlInputStream()
- Returns the InputStream associated with the control Socket connection.
One reads from this stream to obtain data from the remote class's control.
setVerboseFlag
public void setVerboseFlag(boolean v)
- If set true diagnostic messages are printed to System.out.
createControlStreams
public void createControlStreams()
- Create streams to communicate with the control thread using sockets[1]
finalize
protected void finalize()
- Stops the remote class thread.
- Overrides:
- finalize in class Object