All Packages Class Hierarchy This Package Previous Next Index
Class sics.agentbase.sap.SapConnection
java.lang.Object
|
+----sics.agentbase.sap.SapConnection
- public class SapConnection
- extends Object
This class allows JAVA programs to connect to any program/agent in Java
that speaks the SAP protocol. The JAVA program requests for a synchroniouze
connection to be made the other program/agent. It also allows sending
asynchroniouze messages to Java programs/agents. It should be noted that
program that uses this class can NOT receive asynchroniouze messages.
Built on the original SapConnection.java by Niklas Kaltea (nicke@sics.se)
for communication between JAVA programs and Prolog programs/agents.
-
SapConnection()
-
-
SapConnection(Socket)
-
-
connect(String, String, int, String)
- Makes a synchroniouze connection to a Java agent/program.
-
disconnect()
- Disconnect from an open connection.
-
finalize()
-
-
isConnected()
- Tests if we have an open connection.
-
receiveSap()
- Receive a message on an open connection.
-
sendAsyncSap(String, String, int, String, Object)
- Sends a asynchroniouze message.
-
sendSap(Object)
- Send a message on the open connection.
-
shutdown()
- closedown all open streams.
SapConnection
public SapConnection()
SapConnection
public SapConnection(Socket connection) throws IOException
connect
public boolean connect(String owner,
String host,
int port,
String agent)
- Makes a synchroniouze connection to a Java agent/program.
The connection is made to agent at host:port.
This method should be used instead of the Constructor.
- Parameters:
- owner - The name of the one who sends the message.
- host - The host we want to send to.
- port - The port we want to send to.
- agent - The agent we want to send to.
- Returns:
- Returns a referens to the connection or
null
if we failed to open a connection.
disconnect
public void disconnect()
- Disconnect from an open connection.
isConnected
public boolean isConnected()
- Tests if we have an open connection.
- Returns:
-
true or false.
sendSap
public void sendSap(Object sap) throws IOException
- Send a message on the open connection.
- Parameters:
- sap - A serializable object.
- See Also:
- SAP
sendAsyncSap
public static boolean sendAsyncSap(String owner,
String host,
int port,
String agent,
Object msg) throws IOException
- Sends a asynchroniouze message.
The message is sent to agent on host:port.
- Parameters:
- owner - The name of the one who sends the message.
- host - The host we want to send to.
- port - The port we want to send to.
- agent - The agent we want to send to.
- msg - The message object we want to send.
- Returns:
- Returns
true if we succeeds to send the message,
false otherwise.
receiveSap
public Object receiveSap() throws IOException
- Receive a message on an open connection.
This metod blocks until it has read a message from the input stream.
finalize
protected void finalize()
- Overrides:
- finalize in class Object
shutdown
public void shutdown()
- closedown all open streams.
All Packages Class Hierarchy This Package Previous Next Index