org.openmuc.jositransport

## Class ClientTSap

- java.lang.Object
- - org.openmuc.jositransport.ClientTSap

    public final class ClientTSap
    extends java.lang.Object

This class implements a client Transport Service Access Point (TSAP) over TCP/IP as defined in RFC 1006, ISO 8072, and ISO 8073. It can be used to create TConnections that connect to remote ServerTSAPs.

### Field Summary

Fields
`byte[]` `tSelLocal`
`byte[]` `tSelRemote`

### Constructor Summary

Constructors
Constructor and Description
`ClientTSap()` Use this constructor to create a client TSAP that will start connections to remote TSAPs.
`ClientTSap(javax.net.SocketFactory socketFactory)` Use this constructor to create a client TSAP that will start connections to remote TSAPs.

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`TConnection` `connectTo(java.net.InetAddress address, int port)` Connect to a remote TSAP that is listening at the destination address.
`TConnection` `connectTo(java.net.InetAddress address, int port, java.net.InetAddress localAddr, int localPort)` Connect to a remote TSAP that is listening at the destination address.
`static int` `getMaxTPDUSize(int maxTPDUSizeParam)` Calculates and returns the maximum TPDUSize.
`int` `getMaxTPDUSizeParam()` Get the maximum TPDU size parameter to be used by this TSAP
`void` `setMaxTPDUSizeParam(int maxTPduSizeParam)` Set the maxTPDUSize.
`void` `setMessageFragmentTimeout(int messageFragmentTimeout)` Set the TConnection timeout for receiving data once the beginning of a message has been received.
`void` `setMessageTimeout(int messageTimeout)` Set the TConnection timeout for waiting for the first byte of a new message.
`void` `setSocketFactory(javax.net.SocketFactory socketFactory)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### tSelRemote

    public byte[] tSelRemote

#### tSelLocal

    public byte[] tSelLocal

### Constructor Detail

#### ClientTSap

    public ClientTSap()

Use this constructor to create a client TSAP that will start connections to remote TSAPs.

#### ClientTSap

    public ClientTSap(javax.net.SocketFactory socketFactory)

Use this constructor to create a client TSAP that will start connections to remote TSAPs. You could pass an SSLSocketFactory to enable SSL.

Parameters:
  `socketFactory` - the socket factory to create the underlying socket

### Method Detail

#### setMessageTimeout

    public void setMessageTimeout(int messageTimeout)

Set the TConnection timeout for waiting for the first byte of a new message. Default is 0 (unlimited)

Parameters:
  `messageTimeout` - in milliseconds

#### setMessageFragmentTimeout

    public void setMessageFragmentTimeout(int messageFragmentTimeout)

Set the TConnection timeout for receiving data once the beginning of a message has been received. Default is 60000 (60seconds)

Parameters:
  `messageFragmentTimeout` - in milliseconds

#### setMaxTPDUSizeParam

    public void setMaxTPDUSizeParam(int maxTPduSizeParam)

Set the maxTPDUSize. The default maxTPduSize is 65531 (see RFC 1006).

Parameters:
  `maxTPduSizeParam` - The maximum length is equal to 2^(maxTPduSizeParam) octets. Note that the actual TSDU size that can be transfered is equal to TPduSize-3. Default is 65531 octets (see RFC 1006), 7 <= maxTPduSizeParam <= 16, needs to be set before listening or connecting

#### getMaxTPDUSizeParam

    public int getMaxTPDUSizeParam()

Get the maximum TPDU size parameter to be used by this TSAP

Returns:
  the maximum TPDU size parameter

#### getMaxTPDUSize

    public static int getMaxTPDUSize(int maxTPDUSizeParam)

Calculates and returns the maximum TPDUSize. This is equal to 2^(maxTPDUSizeParam)

Parameters:
  `maxTPDUSizeParam` - the size parameter
Returns:
  the maximum TPDU size

#### connectTo

    public TConnection connectTo(java.net.InetAddress address,
                                 int port)
                          throws java.io.IOException

Connect to a remote TSAP that is listening at the destination address.

Parameters:
  `address` - remote IP
  `port` - remote port
Returns:
  the Connection Object
Throws:
  `java.io.IOException` - is thrown if connection was unsuccessful.

#### connectTo

    public TConnection connectTo(java.net.InetAddress address,
                                 int port,
                                 java.net.InetAddress localAddr,
                                 int localPort)
                          throws java.io.IOException

Connect to a remote TSAP that is listening at the destination address.

Parameters:
  `address` - remote IP
  `port` - remote port
  `localAddr` - local IP
  `localPort` - local port
Returns:
  the Connection Object
Throws:
  `java.io.IOException` - is thrown if connection was unsuccessful.

#### setSocketFactory

    public void setSocketFactory(javax.net.SocketFactory socketFactory)