Reality Interface Classes

com.northgateis.comms.dda
Class DDATcp

java.lang.Object
 |
 +--com.northgateis.comms.dda.DDATcp
Direct Known Subclasses:
SNI

public class DDATcp
extends java.lang.Object

Defines an object that creates a DDA TCP connection to a Reality database and supplies methods to access this connection.

Typical usage:

 DDATcp con = new DDATcp("host","database","user","account","server");
 con.connect()
 DDAMsg msg = new DDAMsg(1, 0, "Qualifier".getBytes(), "Data".getBytes());
 con.send(msg)		// as required
 msg = con.receive()		// as required
 con.disconnect()	// not essential as destroying the class will disconnect
 
It is valid to disconnect and reconnect using the same class if required.

Any DDA or IO exception received during the life of a connection will require a new connect() before any more data can be transfered.

Debugging can be turned on by setting the dda.debug property either on the command line or in the reality.properties file. The property should be set to "on". This will result in all DDA messages sent and received being printed on System.err.


Field Summary

static int

DEFAULT_PORT
          The default port used by to connect to a DDA server.

 

Constructor Summary

DDATcp(DDAConnectionSpec spec, java.lang.String server)
          Define a new DDA TCP connection using a DDAConnectionSpec.

DDATcp(java.lang.String host, int port, java.lang.String database, java.lang.String user, java.lang.String account, java.lang.String server)
          Define a new DDA TCP connection for a non default port.

DDATcp(java.lang.String host, java.lang.String database, java.lang.String user, java.lang.String account, java.lang.String server)
          Define a new DDA TCP connection for the default port.

 

Method Summary

 void

connect()
          Connect to the TCP host and the DDA server.

 boolean

dataAvailable()
          Test if data available for input.

static void

debug(boolean on)
          Turn on/off the debug flag.

 void

disconnect()
          Close the TCP connection.

 DDAMsg

receive()
          Receive a DDA message.

 void

send(DDAMsg msg)
          Send a DDA message.

 void

setServer(java.lang.String server)
          Overide the server name used when instantiating the class.

 void

setTimeout(byte Tout)
          Set the timeout when making a connection.

 

Methods inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

DEFAULT_PORT

public static final int DEFAULT_PORT
The default port used by to connect to a DDA server

Constructor Detail

DDATcp

public DDATcp(java.lang.String host,
 int port,
 java.lang.String database,
 java.lang.String user,
 java.lang.String account,
 java.lang.String server)
Define a new DDA TCP connection for a non default port.
Parameters:
host - String specifying the host name to connect to.
port - the port number to use.
database - String specifying the database name to connect to.
user - String specifying the user-id used to connect to the database, with an optional comma separated password
account - String specifying the account used to connect to the database, with an optional comma separated password
server - String specifying server to run

DDATcp

public DDATcp(java.lang.String host,
 java.lang.String database,
 java.lang.String user,
 java.lang.String account,
 java.lang.String server)
Define a new DDA TCP connection for the default port.
Parameters:
host - String specifying the host name to connect to.
database - String specifying the database name to connect to.
user - String specifying the user-id used to connect to the database, with an optional comma separated password
account - String specifying the account used to connect to the database, with an optional comma separated password
server - String specifying server to run

DDATcp

public DDATcp(DDAConnectionSpec spec,
 java.lang.String server)
Define a new DDA TCP connection using a DDAConnectionSpec
Parameters:
spec - DDAConnectionSpec specifying the connection details
server - String specifying server to run
Method Detail

connect

public void connect()
 throws java.io.IOException,
 com.northgateis.comms.dda.DDAException
Connect to the TCP host and the DDA server.
Throws:
java.io.IOException - if an error occurs during the TCP connection
com.northgateis.comms.dda.DDAException - if an error occurs during the DDA negotiation

disconnect

public void disconnect()
Close the TCP connection

send

public void send(DDAMsg msg)
 throws java.io.IOException
Send a DDA message.
Parameters:
msg - the DDAMsg to send.
Throws:
java.io.IOException - if an input or output exception occurs

receive

public DDAMsgreceive()
 throws java.io.IOException
Receive a DDA message
Returns:
DDAMsg containing the received data
Throws:
java.io.IOException - if an input or output exception occurs

dataAvailable

public boolean dataAvailable()
 throws java.io.IOException
Test if data available for input
Returns:
true if data available, false otherwise
Throws:
java.io.IOException - if an input or output exception occurs

setTimeout

public void setTimeout(byte Tout)
Set the timeout when making a connection
Parameters:
Tout - the connection timeout in minutes

debug

public static void debug(boolean on)
Turn on/off the debug flag. When debugging is turned on all messages sent and received are dumped to System.err in ASCII hex format.
Parameters:
on - true to turn debugging on, false to turn it off

setServer

public void setServer(java.lang.String server)
Overide the server name used when instantiating the class.
Parameters:
server - Name of the server to use.

Reality Interface Classes

Copyright (c) 2000 NEC Software Services (UK) Limited