public class ClientSap
extends java.lang.Object
connect
function is called to connect to the server. An
instance of ClientSap can be used to create an unlimited number of connections. Changing the parameters of a
ClientSap 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 ClientSap are those most commonly used in IEC 60870-5-104 communication.Constructor and Description |
---|
ClientSap()
Use this constructor to create a default client SAP that uses
SocketFactory.getDefault() as its
SocketFactory. |
ClientSap(javax.net.SocketFactory socketFactory)
Use this constructor to create a client SAP that uses the given
SocketFactory to connect to servers. |
Modifier and Type | Method and Description |
---|---|
Connection |
connect(java.net.InetAddress address)
Connects to the given address on port 2404.
|
Connection |
connect(java.net.InetAddress address,
int port)
Connects to the given address and port.
|
Connection |
connect(java.net.InetAddress address,
int port,
java.net.InetAddress localAddr,
int localPort)
Connects to the given address and port.
|
void |
setCommonAddressFieldLength(int length)
Sets the length of the Common Address (CA) field of the ASDU.
|
void |
setCotFieldLength(int length)
Sets the length of the Cause Of Transmission (COT) field of the ASDU.
|
void |
setIoaFieldLength(int length)
Sets the length of the Information Object Address (IOA) field of the ASDU.
|
void |
setMaxIdleTime(int time)
Sets the maximum time in ms that the connection may be idle before sending a test frame.
|
void |
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.
|
void |
setMaxTimeNoAckSent(int time)
Sets the maximum time in ms before confirming received messages that have not yet been acknowledged using an S
format APDU.
|
void |
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.
|
void |
setMessageFragmentTimeout(int timeout)
Sets the message fragment timeout.
|
public ClientSap()
SocketFactory.getDefault()
as its
SocketFactory.public ClientSap(javax.net.SocketFactory socketFactory)
SocketFactory
to connect to servers.
You could pass an SSLSocketFactory to enable SSL.socketFactory
- the socket factorypublic void setMessageFragmentTimeout(int timeout)
interrogation
) will throw
an IOException if the socket throws this timeout. In addition any ASDU listener will be notified of the
IOException. Usually the connection cannot recover from this kind of error.timeout
- the timeout in milliseconds. The default is 5000.public void setCotFieldLength(int length)
length
- the length of the Cause Of Transmission fieldpublic void setCommonAddressFieldLength(int length)
length
- the length of the Common Address (CA) fieldpublic void setIoaFieldLength(int length)
length
- the length of the Information Object Address fieldpublic void setMaxTimeNoAckReceived(int time)
time
- the maximum time in ms that no acknowledgement has been received before actively closing the
connection.public void 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 void setMaxIdleTime(int time)
time
- the maximum time in ms that the connection may be idle before sending a test frame.public void 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.public Connection connect(java.net.InetAddress address) throws java.io.IOException
address
- the address to connect tojava.io.IOException
- if any kind of error occurs during connection build up.public Connection connect(java.net.InetAddress address, int port) throws java.io.IOException
address
- the address to connect toport
- the port to connect to. The IEC 60870-5-104 standard specifies the use of port 2404.java.io.IOException
- if any kind of error occurs during connection build up.public Connection connect(java.net.InetAddress address, int port, java.net.InetAddress localAddr, int localPort) throws java.io.IOException
address
- the address to connect toport
- the port to connect to. The IEC 60870-5-104 standard specifies the use of port 2404.localAddr
- the local address the socket is bound to, or null for anyLocal address.localPort
- the local port the socket is bound to or zero for a system selected free port.java.io.IOException
- if any kind of error occurs during connection build up.