Class NioSctpChannel

All Implemented Interfaces:
Channel, ChannelOutboundInvoker, SctpChannel, AttributeMap, java.lang.Comparable<Channel>

public class NioSctpChannel extends AbstractNioMessageChannel implements SctpChannel
SctpChannel implementation which use non-blocking mode and allows to read / write SctpMessages to the underlying SctpChannel. Be aware that not all operations systems support SCTP. Please refer to the documentation of your operation system, to understand what you need to do to use it. Also this feature is only supported on Java 7+.
  • Field Details

    • METADATA

      private static final ChannelMetadata METADATA
    • logger

      private static final InternalLogger logger
    • config

      private final SctpChannelConfig config
    • notificationHandler

      private final NotificationHandler<?> notificationHandler
    • inputCopy

      private java.nio.ByteBuffer inputCopy
    • outputCopy

      private java.nio.ByteBuffer outputCopy
  • Constructor Details

    • NioSctpChannel

      public NioSctpChannel()
      Create a new instance
    • NioSctpChannel

      public NioSctpChannel(SctpChannel sctpChannel)
      Create a new instance using SctpChannel
    • NioSctpChannel

      public NioSctpChannel(Channel parent, SctpChannel sctpChannel)
      Create a new instance
      Parameters:
      parent - the Channel which is the parent of this NioSctpChannel or null.
      sctpChannel - the underlying SctpChannel
  • Method Details

    • newSctpChannel

      private static SctpChannel newSctpChannel()
    • localAddress

      public java.net.InetSocketAddress localAddress()
      Description copied from interface: Channel
      Returns the local address where this channel is bound to. The returned SocketAddress is supposed to be down-cast into more concrete type such as InetSocketAddress to retrieve the detailed information.
      Specified by:
      localAddress in interface Channel
      Specified by:
      localAddress in interface SctpChannel
      Overrides:
      localAddress in class AbstractChannel
      Returns:
      the local address of this channel. null if this channel is not bound.
    • remoteAddress

      public java.net.InetSocketAddress remoteAddress()
      Description copied from interface: Channel
      Returns the remote address where this channel is connected to. The returned SocketAddress is supposed to be down-cast into more concrete type such as InetSocketAddress to retrieve the detailed information.
      Specified by:
      remoteAddress in interface Channel
      Specified by:
      remoteAddress in interface SctpChannel
      Overrides:
      remoteAddress in class AbstractChannel
      Returns:
      the remote address of this channel. null if this channel is not connected. If this channel is not connected but it can receive messages from arbitrary remote addresses (e.g. DatagramChannel, use DefaultAddressedEnvelope.recipient() to determine the origination of the received message as this method will return null.
    • parent

      public SctpServerChannel parent()
      Description copied from interface: Channel
      Returns the parent of this channel.
      Specified by:
      parent in interface Channel
      Specified by:
      parent in interface SctpChannel
      Overrides:
      parent in class AbstractChannel
      Returns:
      the parent channel. null if this channel does not have a parent channel.
    • metadata

      public ChannelMetadata metadata()
      Description copied from interface: Channel
      Return the ChannelMetadata of the Channel which describe the nature of the Channel.
      Specified by:
      metadata in interface Channel
    • association

      public Association association()
      Description copied from interface: SctpChannel
      Returns the underlying SCTP association.
      Specified by:
      association in interface SctpChannel
    • allLocalAddresses

      public java.util.Set<java.net.InetSocketAddress> allLocalAddresses()
      Description copied from interface: SctpChannel
      Return all local addresses of the SCTP channel. Please note that, it will return more than one address if this channel is using multi-homing
      Specified by:
      allLocalAddresses in interface SctpChannel
    • config

      public SctpChannelConfig config()
      Description copied from interface: Channel
      Returns the configuration of this channel.
      Specified by:
      config in interface Channel
      Specified by:
      config in interface SctpChannel
    • allRemoteAddresses

      public java.util.Set<java.net.InetSocketAddress> allRemoteAddresses()
      Description copied from interface: SctpChannel
      Return all remote addresses of the SCTP server channel. Please note that, it will return more than one address if the remote is using multi-homing.
      Specified by:
      allRemoteAddresses in interface SctpChannel
    • javaChannel

      protected SctpChannel javaChannel()
      Overrides:
      javaChannel in class AbstractNioChannel
    • isActive

      public boolean isActive()
      Description copied from interface: Channel
      Return true if the Channel is active and so connected.
      Specified by:
      isActive in interface Channel
    • localAddress0

      protected java.net.SocketAddress localAddress0()
      Description copied from class: AbstractChannel
      Returns the SocketAddress which is bound locally.
      Specified by:
      localAddress0 in class AbstractChannel
    • remoteAddress0

      protected java.net.SocketAddress remoteAddress0()
      Description copied from class: AbstractChannel
      Return the SocketAddress which the Channel is connected to.
      Specified by:
      remoteAddress0 in class AbstractChannel
    • doBind

      protected void doBind(java.net.SocketAddress localAddress) throws java.lang.Exception
      Description copied from class: AbstractChannel
      Bind the Channel to the SocketAddress
      Specified by:
      doBind in class AbstractChannel
      Throws:
      java.lang.Exception
    • doConnect

      protected boolean doConnect(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress) throws java.lang.Exception
      Description copied from class: AbstractNioChannel
      Connect to the remote peer
      Specified by:
      doConnect in class AbstractNioChannel
      Throws:
      java.lang.Exception
    • doFinishConnect

      protected void doFinishConnect() throws java.lang.Exception
      Description copied from class: AbstractNioChannel
      Finish the connect
      Specified by:
      doFinishConnect in class AbstractNioChannel
      Throws:
      java.lang.Exception
    • doDisconnect

      protected void doDisconnect() throws java.lang.Exception
      Description copied from class: AbstractChannel
      Disconnect this Channel from its remote peer
      Specified by:
      doDisconnect in class AbstractChannel
      Throws:
      java.lang.Exception
    • doClose

      protected void doClose() throws java.lang.Exception
      Description copied from class: AbstractChannel
      Close the Channel
      Overrides:
      doClose in class AbstractNioChannel
      Throws:
      java.lang.Exception
    • doReadMessages

      protected int doReadMessages(java.util.List<java.lang.Object> buf) throws java.lang.Exception
      Description copied from class: AbstractNioMessageChannel
      Read messages into the given array and return the amount which was read.
      Specified by:
      doReadMessages in class AbstractNioMessageChannel
      Throws:
      java.lang.Exception
    • doWriteMessage

      protected boolean doWriteMessage(java.lang.Object msg, ChannelOutboundBuffer in) throws java.lang.Exception
      Description copied from class: AbstractNioMessageChannel
      Write a message to the underlying Channel.
      Specified by:
      doWriteMessage in class AbstractNioMessageChannel
      Returns:
      true if and only if the message has been written
      Throws:
      java.lang.Exception
    • filterOutboundMessage

      protected final java.lang.Object filterOutboundMessage(java.lang.Object msg) throws java.lang.Exception
      Description copied from class: AbstractChannel
      Invoked when a new message is added to a ChannelOutboundBuffer of this AbstractChannel, so that the Channel implementation converts the message to another. (e.g. heap buffer -> direct buffer)
      Overrides:
      filterOutboundMessage in class AbstractChannel
      Throws:
      java.lang.Exception
    • bindAddress

      public ChannelFuture bindAddress(java.net.InetAddress localAddress)
      Description copied from interface: SctpChannel
      Bind a address to the already bound channel to enable multi-homing. The Channel bust be bound and yet to be connected.
      Specified by:
      bindAddress in interface SctpChannel
    • bindAddress

      public ChannelFuture bindAddress(java.net.InetAddress localAddress, ChannelPromise promise)
      Description copied from interface: SctpChannel
      Bind a address to the already bound channel to enable multi-homing. The Channel bust be bound and yet to be connected. Will notify the given ChannelPromise and return a ChannelFuture
      Specified by:
      bindAddress in interface SctpChannel
    • unbindAddress

      public ChannelFuture unbindAddress(java.net.InetAddress localAddress)
      Description copied from interface: SctpChannel
      Unbind the address from channel's multi-homing address list. The address should be added already in multi-homing address list.
      Specified by:
      unbindAddress in interface SctpChannel
    • unbindAddress

      public ChannelFuture unbindAddress(java.net.InetAddress localAddress, ChannelPromise promise)
      Description copied from interface: SctpChannel
      Unbind the address from channel's multi-homing address list. The address should be added already in multi-homing address list. Will notify the given ChannelPromise and return a ChannelFuture
      Specified by:
      unbindAddress in interface SctpChannel