Class 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).
    • 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • open

        public void open()
                  throws java.io.IOException
        Description copied from interface: TransportLayer
        Opens the physical layer.
        Specified by:
        open in interface TransportLayer
        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 the InputStreamm 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 interface StreamAccessor
        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 interface StreamAccessor
        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 interface StreamAccessor
        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 interface java.lang.AutoCloseable
        Specified by:
        close in interface StreamAccessor
        Throws:
        java.io.IOException
      • isClosed

        public boolean isClosed()
        Description copied from interface: TransportLayer
        Status of the connection/transport layer.
        Specified by:
        isClosed in interface TransportLayer
        Returns:
        true if the connection is closes false otherwhise.