Class UdpLayer
- java.lang.Object
-
- org.openmuc.jdlms.transportlayer.client.UdpLayer
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,TransportLayer
,StreamAccessor
public class UdpLayer extends java.lang.Object implements TransportLayer
The transport layer used to communicate via the User Datagram Protocol (UDP).
-
-
Field Summary
Fields Modifier and Type Field Description static int
MAX_UDP_PAYLOAD_SIZE
-
Constructor Summary
Constructors Constructor Description UdpLayer(TcpSettings settings)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
java.io.DataInputStream
getInputStream()
Returns the input stream for this stream accessor.java.io.DataOutputStream
getOutpuStream()
Returns the output stream for this stream accessor.boolean
isClosed()
Status of the connection/transport layer.void
open()
Opens the physical layer.void
setTimeout(int timeout)
Enable/disable TIMEOUT with the specified timeout, in milliseconds.
-
-
-
Field Detail
-
MAX_UDP_PAYLOAD_SIZE
public static final int MAX_UDP_PAYLOAD_SIZE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
UdpLayer
public UdpLayer(TcpSettings settings)
-
-
Method Detail
-
open
public void open() throws java.io.IOException
Description copied from interface:TransportLayer
Opens the physical layer.- Specified by:
open
in interfaceTransportLayer
- Throws:
java.io.IOException
- if an error occurred opening the stream.
-
setTimeout
public void setTimeout(int timeout) throws java.io.IOException
Description copied from interface:StreamAccessor
Enable/disable TIMEOUT with the specified timeout, in milliseconds. With this option set to a non-zero timeout, a read() call on theInputStream
m associated with this StreamAcessor will block for only this amount of time. If the timeout expires, a java.net.SocketTimeoutException is raised, though the Socket is still valid. The option must be enabled prior to entering the blocking operation to have effect. The timeout must be> 0
. A timeout of zero is interpreted as an infinite timeout.- Specified by:
setTimeout
in interfaceStreamAccessor
- Parameters:
timeout
- the specified timeout, in milliseconds.- Throws:
java.io.IOException
- if there is an error in the underlying protocol, such as a TCP error.
-
getInputStream
public java.io.DataInputStream getInputStream() throws java.io.IOException
Description copied from interface:StreamAccessor
Returns the input stream for this stream accessor.- Specified by:
getInputStream
in interfaceStreamAccessor
- Returns:
- the input stream.
- Throws:
java.io.IOException
- an I/O error accessing the input stream, the stream accessor is closed, the stream accessor is not connected.
-
getOutpuStream
public java.io.DataOutputStream getOutpuStream() throws java.io.IOException
Description copied from interface:StreamAccessor
Returns the output stream for this stream accessor.- Specified by:
getOutpuStream
in interfaceStreamAccessor
- Returns:
- the output stream.
- Throws:
java.io.IOException
- an I/O error accessing the output stream, the stream accessor is closed, the stream accessor is not connected.
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfaceStreamAccessor
- Throws:
java.io.IOException
-
isClosed
public boolean isClosed()
Description copied from interface:TransportLayer
Status of the connection/transport layer.- Specified by:
isClosed
in interfaceTransportLayer
- Returns:
true
if the connection is closesfalse
otherwhise.
-
-