org.openmuc.j60870
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 |
setMaxIPdusReceivedWithoutAck(int maxNum)
Sets the maximum number of I format APDUs frames after which the client connection will automatically send an S
format APDU to confirm them.
|
void |
setMaxTimeWithoutAck(int time)
Sets the maximum time in ms before confirming received messages using an S format APDU.
|
void |
setMessageFragmentTimeout(int timeout)
Sets the message fragment timeout.
|
void |
setResponseTimeout(int timeout)
Sets the default response timeout of the
connections created using this ClientSap. |
void |
setWaitForConfirmation(boolean wait)
Sets whether the different command methods of
Connection shall wait for confirmation messages or not
before returning. |
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.public void setResponseTimeout(int timeout)
connections
created using this ClientSap. The
response timeout is the maximum time that the client will wait for the confirmation message (CON) after sending a
command. If such a timeout occurs the corresponding command function (e.g.
interrogation
) will throw
a TimeoutException.timeout
- the response timeout in milliseconds. The default is 10000 (10s).public 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 10000.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 setMaxTimeWithoutAck(int time)
time
- the maximum time in ms before confirming received messages using an S format APDU. Default is 10000.public void setMaxIPdusReceivedWithoutAck(int maxNum)
maxNum
- the maximum number of I format APDUs frames after which the client connection will automatically send
an S format APDU to confirm them. Default is 10.public void setWaitForConfirmation(boolean wait)
Connection
shall wait for confirmation messages or not
before returning. If set to true the command message will only return after a confirmation message was received
or a timeout is thrown. If set to false the command functions will return immediately after the command message
was sent.wait
- whether the different command methods of ClientSap
shall wait for confirmation messages
or not. Default is true.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.