Package org.openmuc.j60870
Class Server.Builder
- java.lang.Object
-
- org.openmuc.j60870.Server.Builder
-
- Enclosing class:
- Server
public static class Server.Builder extends java.lang.Object
The server builder which builds a 60870 server instance.- See Also:
Server.builder()
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Server
build()
To start/activate the server callServer.start(ServerEventListener)
on the returned server.T
setAllowedASduTypes(java.util.List<ASduType> allowedTypes)
Server.Builder
setAllowedClients(java.util.List<java.lang.String> allowedClientIps)
Set the IPs from which clients may connect.Server.Builder
setBacklog(int backlog)
Sets the backlog that is passed to the java.net.ServerSocket.Server.Builder
setBindAddr(java.net.InetAddress bindAddr)
Sets the IP address to bind to.T
setCommonAddressFieldLength(int length)
Sets the length of the Common Address (CA) field of the ASDU.
Allowed values are 1 or 2.
Default is 2.T
setCotFieldLength(int length)
Sets the length of the Cause Of Transmission (COT) field of the ASDU.
Allowed values are 1 or 2.
Default is 2.T
setIoaFieldLength(int length)
Sets the length of the Information Object Address (IOA) field of the ASDU.
Allowed values are 1, 2 or 3.
Default is 3.Server.Builder
setMaxConnections(int maxConnections)
Set the maximum number of client connections that are allowed in parallel.T
setMaxIdleTime(int time_t3)
Sets the maximum time in ms that the connection may be idle before sending a test frame.T
setMaxNumOfOutstandingIPdus(int maxNum)
Sets the number of maximum difference send sequence number to send acknowledge variable before Connection.send will block.T
setMaxTimeNoAckReceived(int time_t1)
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_t2)
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.T
setMessageFragmentTimeout(int time)
Sets SO_TIMEOUT with the specified timeout, in milliseconds.Server.Builder
setPort(int port)
Sets the TCP port that the server will listen on.void
setReservedASduTypeDecoder(ReservedASduTypeDecoder reservedASduTypeDecoder)
Sets an implementation of the ReservedASduTypeDecoder to define supported reserved ASdusServer.Builder
setSocketFactory(javax.net.ServerSocketFactory socketFactory)
Sets the ServerSocketFactory to be used to create the ServerSocket.T
useSharedThreadPool()
-
-
-
Method Detail
-
setPort
public Server.Builder setPort(int port)
Sets the TCP port that the server will listen on. IEC 60870-5-104 usually uses port 2404.- Parameters:
port
- the port- Returns:
- this builder
-
setBacklog
public Server.Builder setBacklog(int backlog)
Sets the backlog that is passed to the java.net.ServerSocket.- Parameters:
backlog
- the backlog- Returns:
- this builder
-
setReservedASduTypeDecoder
public void setReservedASduTypeDecoder(ReservedASduTypeDecoder reservedASduTypeDecoder)
Sets an implementation of the ReservedASduTypeDecoder to define supported reserved ASdus- Parameters:
reservedASduTypeDecoder
- implementation of the ReservedASduTypeDecoder
-
setBindAddr
public Server.Builder setBindAddr(java.net.InetAddress bindAddr)
Sets the IP address to bind to. It is passed to java.net.ServerSocket- Parameters:
bindAddr
- the IP address to bind to- Returns:
- this builder
-
setSocketFactory
public Server.Builder setSocketFactory(javax.net.ServerSocketFactory socketFactory)
Sets the ServerSocketFactory to be used to create the ServerSocket. Default is ServerSocketFactory.getDefault().- Parameters:
socketFactory
- the ServerSocketFactory to be used to create the ServerSocket- Returns:
- this builder
-
setMaxConnections
public Server.Builder setMaxConnections(int maxConnections)
Set the maximum number of client connections that are allowed in parallel.- Parameters:
maxConnections
- the number of connections allowed (default is 100) @ return this builder- Returns:
- this builder
-
setAllowedClients
public Server.Builder setAllowedClients(java.util.List<java.lang.String> allowedClientIps)
Set the IPs from which clients may connect. Passnull
to allow all clients. By default all clients are allowed to connect.- Parameters:
allowedClientIps
- the allowed client IPs- Returns:
- this builder
-
build
public Server build()
To start/activate the server callServer.start(ServerEventListener)
on the returned server.
-
setCotFieldLength
public T setCotFieldLength(int length)
Sets the length of the Cause Of Transmission (COT) field of the ASDU.
Allowed values are 1 or 2.
Default is 2.- Parameters:
length
- the length of the Cause Of Transmission field- Returns:
- this builder
-
setCommonAddressFieldLength
public T setCommonAddressFieldLength(int length)
Sets the length of the Common Address (CA) field of the ASDU.
Allowed values are 1 or 2.
Default is 2.- Parameters:
length
- the length of the Common Address (CA) field- Returns:
- this builder
-
setIoaFieldLength
public T setIoaFieldLength(int length)
Sets the length of the Information Object Address (IOA) field of the ASDU.
Allowed values are 1, 2 or 3.
Default is 3.- Parameters:
length
- the length of the Information Object Address field- Returns:
- this builder
-
setMaxTimeNoAckReceived
public T setMaxTimeNoAckReceived(int time_t1)
Sets the maximum time in ms that no acknowledgement has been received (for I-Frames or Test-Frames) before actively closing the connection. This timeout is called t1 by the standard.
Default is 15s, minimum is 1s, maximum is 255s.
t1 (maxTimeNoAckReceived) has to be greater then t2 (maxTimeNoAckSent) and t1 has to be smaller then t3 (maxIdleTime) (t1 > t2 and t1 < t3)- Parameters:
time_t1
- the maximum time in ms that no acknowledgement has been received before actively closing the connection.- Returns:
- this builder
-
setMaxTimeNoAckSent
public T setMaxTimeNoAckSent(int time_t2)
Sets the maximum time in ms before confirming received messages that have not yet been acknowledged using an S format APDU. This timeout is called t2 by the standard.
Default is 10s, minimum is 1s, maximum is 255s.
t2 (maxTimeNoAckSent) has to be smaller then t1 (maxTimeNoAckReceived), t3 > t1.- Parameters:
time_t2
- the maximum time in ms before confirming received messages that have not yet been acknowledged using an S format APDU.- Returns:
- this builder
-
setMaxIdleTime
public T setMaxIdleTime(int time_t3)
Sets the maximum time in ms that the connection may be idle before sending a test frame. This timeout is called t3 by the standard.
Default is 20s, minimum is 1s, maximum is 172800s (48h).
t3 (maxIdleTime) has to be bigger then t1 (maxTimeNoAckReceived), t3 > t1.- Parameters:
time_t3
- the maximum time in ms that the connection may be idle before sending a test frame.- Returns:
- this builder
-
setMaxNumOfOutstandingIPdus
public T setMaxNumOfOutstandingIPdus(int maxNum)
Sets the number of maximum difference send sequence number to send acknowledge variable before Connection.send will block. This parameter is called k by the standard.
Default is 12, minimum is 1, maximum is 32767.- Parameters:
maxNum
- the maximum number of sequentially numbered I format APDUs that the DTE may have outstanding- Returns:
- this builder
-
setMaxUnconfirmedIPdusReceived
public 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. This parameter is called w by the standard. Default is 8, minimum is 1, maximum is 32767.- Parameters:
maxNum
- the number of unacknowledged I format APDUs received before the connection will automatically send an S format APDU to confirm them.- Returns:
- this builder
-
setMessageFragmentTimeout
public T setMessageFragmentTimeout(int time)
Sets SO_TIMEOUT with the specified timeout, in milliseconds.- Parameters:
time
- the timeout in milliseconds. Default is 5 s, minimum 100 ms.- Returns:
- this builder
-
useSharedThreadPool
public T useSharedThreadPool()
-
setAllowedASduTypes
public T setAllowedASduTypes(java.util.List<ASduType> allowedTypes)
-
-