Class DatagramServerConnector

All Implemented Interfaces:
Closeable, AutoCloseable, Connector, NetworkConnector, Container, Destroyable, Dumpable, Dumpable.DumpableContainer, Graceful, LifeCycle
Direct Known Subclasses:
QuicheServerConnector

public class DatagramServerConnector extends AbstractNetworkConnector
  • Constructor Details

  • Method Details

    • getLocalPort

      public int getLocalPort()
      Specified by:
      getLocalPort in interface NetworkConnector
      Overrides:
      getLocalPort in class AbstractNetworkConnector
      Returns:
      The actual port the connector is listening on, or -1 if it has not been opened, or -2 if it has been closed.
    • isOpen

      public boolean isOpen()
      Description copied from interface: NetworkConnector
      A Connector may be opened and not started (to reserve a port) or closed and running (to allow graceful shutdown of existing connections)
      Returns:
      True if the connector is Open.
    • doStart

      protected void doStart() throws Exception
      Description copied from class: ContainerLifeCycle
      Starts the managed lifecycle beans in the order they were added.
      Overrides:
      doStart in class AbstractNetworkConnector
      Throws:
      Exception - If there was a problem starting. Will cause a transition to FAILED state
    • open

      public void open() throws IOException
      Description copied from interface: NetworkConnector

      Performs the activities needed to open the network communication (for example, to start accepting incoming network connections).

      Implementation must be idempotent.

      Specified by:
      open in interface NetworkConnector
      Overrides:
      open in class AbstractNetworkConnector
      Throws:
      IOException - if this connector cannot be opened
      See Also:
    • openDatagramChannel

      protected DatagramChannel openDatagramChannel() throws IOException
      Throws:
      IOException
    • setIdleTimeout

      public void setIdleTimeout(long idleTimeout)
      Description copied from class: AbstractConnector

      Sets the maximum Idle time for a connection, which roughly translates to the Socket.setSoTimeout(int) call, although with NIO implementations other mechanisms may be used to implement the timeout.

      The max idle time is applied:

      • When waiting for a new message to be received on a connection
      • When waiting for a new message to be sent on a connection

      This value is interpreted as the maximum time between some progress being made on the connection. So if a single byte is read or written, then the timeout is reset.

      Overrides:
      setIdleTimeout in class AbstractConnector
      Parameters:
      idleTimeout - the idle timeout
    • doStop

      protected void doStop() throws Exception
      Description copied from class: ContainerLifeCycle
      Stops the managed lifecycle beans in the reverse order they were added.
      Overrides:
      doStop in class AbstractNetworkConnector
      Throws:
      Exception - If there was a problem stopping. Will cause a transition to FAILED state
    • close

      public void close()
      Description copied from interface: NetworkConnector

      Performs the activities needed to close the network communication (for example, to stop accepting network connections).

      Once a connector has been closed, it cannot be opened again without first calling LifeCycle.stop() and it will not be active again until a subsequent call to LifeCycle.start().

      Implementation must be idempotent.

      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface NetworkConnector
      Overrides:
      close in class AbstractNetworkConnector
    • getTransport

      public Object getTransport()
      Description copied from interface: Connector
      Get the underlying socket, channel, buffer etc. for the connector..
      Returns:
      the underlying socket, channel, buffer etc. for the connector.
    • accept

      protected void accept(int acceptorID)
      Specified by:
      accept in class AbstractConnector
    • newEndPoint

      protected EndPoint newEndPoint(DatagramChannel channel, ManagedSelector selector, SelectionKey selectionKey)
    • newConnection

      protected Connection newConnection(EndPoint endpoint)