org.openmuc.jositransport

## Class TConnection

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

    public final class TConnection
    extends java.lang.Object

### Field Summary

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

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `close()` Will close the TCP connection if its still open and free any resources of this connection.
`void` `disconnect()` This function sends a Disconnect Request but does not wait for a Disconnect Confirm.
`int` `getMessageFragmentTimeout()`
`int` `getMessageTimeout()`
`void` `receive(java.nio.ByteBuffer tSduBuffer)` Listens for a new TPDU and writes the extracted TSDU into the passed buffer.
`void` `send(byte[] tsdu, int offset, int length)`
`void` `send(java.util.List<byte[]> tsdus, java.util.List<java.lang.Integer> offsets, java.util.List<java.lang.Integer> lengths)`
`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.

### 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

### Method Detail

#### send

    public void send(java.util.List<byte[]> tsdus,
                     java.util.List<java.lang.Integer> offsets,
                     java.util.List<java.lang.Integer> lengths)
              throws java.io.IOException

Throws:
  `java.io.IOException`

#### send

    public void send(byte[] tsdu,
                     int offset,
                     int length)
              throws java.io.IOException

Throws:
  `java.io.IOException`

#### getMessageTimeout

    public int getMessageTimeout()

#### 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

#### getMessageFragmentTimeout

    public int getMessageFragmentTimeout()

#### 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 (60 seconds)

Parameters:
  `messageFragmentTimeout` - in milliseconds

#### receive

    public void receive(java.nio.ByteBuffer tSduBuffer)
                 throws java.io.EOFException,
                        java.net.SocketTimeoutException,
                        java.io.IOException,
                        java.util.concurrent.TimeoutException

Listens for a new TPDU and writes the extracted TSDU into the passed buffer.

Parameters:
  `tSduBuffer` - the buffer that is filled with the received TSDU data.
Throws:
  `java.io.EOFException` - if a Disconnect Request (DR) was received or the socket was simply closed
  `java.net.SocketTimeoutException` - if a messageFragmentTimeout is thrown by the socket while receiving the remainder of a message
  `java.io.IOException` - if an ErrorPDU (ER) was received, any syntax error in the received message header was detected or the tSduBuffer is too small to hold the complete PDU.
  `java.util.concurrent.TimeoutException` - this exception is thrown if the first byte of new message is not received within the message timeout.

#### disconnect

    public void disconnect()

This function sends a Disconnect Request but does not wait for a Disconnect Confirm.

#### close

    public void close()

Will close the TCP connection if its still open and free any resources of this connection.