public class ClientConnectionBuilder
extends java.lang.Object
ClientConnectionBuilder
. Next all the necessary
configuration parameters can be set. Finally the connect
function is called
to connect to the server. An instance of ClientConnectionBuilder
can be used to create an unlimited number of
connections. Changing the parameters of a ClientConnectionBuilder
has no affect on connections that have
already been created.
Note that the configured lengths of the fields COT, CA and IOA have to be the same for all communicating nodes in a
network. The default values used by ClientConnectionBuilder
are those most commonly used in IEC 60870-5-104
communication.Constructor and Description |
---|
ClientConnectionBuilder(java.net.InetAddress address)
Creates a client connection builder that can be used to connect to the given address.
|
Modifier and Type | Method and Description |
---|---|
Connection |
connect()
Connects to the server.
|
ClientConnectionBuilder |
setAddress(java.net.InetAddress address)
Sets the address to connect to.
|
T |
setCommonAddressFieldLength(int length)
Sets the length of the Common Address (CA) field of the ASDU.
|
T |
setCotFieldLength(int length)
Sets the length of the Cause Of Transmission (COT) field of the ASDU.
|
T |
setIoaFieldLength(int length)
Sets the length of the Information Object Address (IOA) field of the ASDU.
|
ClientConnectionBuilder |
setLocalAddress(java.net.InetAddress address,
int port)
Sets the local (client) address and port the socket will connect to.
|
T |
setMaxIdleTime(int time)
Sets the maximum time in ms that the connection may be idle before sending a test frame.
|
T |
setMaxTimeNoAckReceived(int time)
Sets the maximum time in ms that no acknowledgement has been received (for I-Frames or Test-Frames) before
actively closing the connection.
|
T |
setMaxTimeNoAckSent(int time)
Sets the maximum time in ms before confirming received messages that have not yet been acknowledged using an S
format APDU.
|
T |
setMaxUnconfirmedIPdusReceived(int maxNum)
Sets the number of unacknowledged I format APDUs received before the connection will automatically send an S
format APDU to confirm them.
|
ClientConnectionBuilder |
setPort(int port)
Sets the port to connect to.
|
ClientConnectionBuilder |
setSocketFactory(javax.net.SocketFactory socketFactory)
Set the socket factory to used to create the socket for the connection.
|
public ClientConnectionBuilder(java.net.InetAddress address)
address
- the address to connect topublic ClientConnectionBuilder setSocketFactory(javax.net.SocketFactory socketFactory)
SocketFactory.getDefault()
. You could pass an SSLSocketFactory
to enable SSL.socketFactory
- the socket factorypublic ClientConnectionBuilder setPort(int port)
port
- the port to connect to.public ClientConnectionBuilder setAddress(java.net.InetAddress address)
address
- the address to connect to.public ClientConnectionBuilder setLocalAddress(java.net.InetAddress address, int port)
address
- the local address the socket is bound to, or null for any local address.port
- the local port the socket is bound to or zero for a system selected free port.public Connection connect() throws java.io.IOException
Connection
object is returned that can be
used to communicate with the server.Connection
object that can be used to communicate with the server.java.io.IOException
- if any kind of error occurs during connection build up.public T setCotFieldLength(int length)
length
- the length of the Cause Of Transmission fieldpublic T setCommonAddressFieldLength(int length)
length
- the length of the Common Address (CA) fieldpublic T setIoaFieldLength(int length)
length
- the length of the Information Object Address fieldpublic T setMaxTimeNoAckReceived(int time)
time
- the maximum time in ms that no acknowledgement has been received before actively closing the
connection.public T setMaxTimeNoAckSent(int time)
time
- the maximum time in ms before confirming received messages that have not yet been acknowledged using
an S format APDU.public T setMaxIdleTime(int time)
time
- the maximum time in ms that the connection may be idle before sending a test frame.public T setMaxUnconfirmedIPdusReceived(int maxNum)
maxNum
- the number of unacknowledged I format APDUs received before the connection will automatically send an
S format APDU to confirm them.