Interface IoAcceptor

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void bind()
      Binds to the default local address(es) and start to accept incoming connections.
      void bind​(java.lang.Iterable<? extends java.net.SocketAddress> localAddresses)
      Binds to the specified local addresses and start to accept incoming connections.
      void bind​(java.net.SocketAddress localAddress)
      Binds to the specified local address and start to accept incoming connections.
      void bind​(java.net.SocketAddress... addresses)
      Binds to the specified local addresses and start to accept incoming connections.
      void bind​(java.net.SocketAddress firstLocalAddress, java.net.SocketAddress... addresses)
      Binds to the specified local addresses and start to accept incoming connections.
      java.net.SocketAddress getDefaultLocalAddress()
      Returns the default local address to bind when no argument is specified in bind() method.
      java.util.List<java.net.SocketAddress> getDefaultLocalAddresses()
      Returns a List of the default local addresses to bind when no argument is specified in bind() method.
      java.net.SocketAddress getLocalAddress()
      Returns the local address which is bound currently.
      java.util.Set<java.net.SocketAddress> getLocalAddresses()
      Returns a Set of the local addresses which are bound currently.
      boolean isCloseOnDeactivation()
      Returns true if and only if all clients are closed when this acceptor unbinds from all the related local address (i.e.
      IoSession newSession​(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress)
      (Optional) Returns an IoSession that is bound to the specified localAddress and the specified remoteAddress which reuses the local address that is already bound by this service.
      void setCloseOnDeactivation​(boolean closeOnDeactivation)
      Sets whether all client sessions are closed when this acceptor unbinds from all the related local addresses (i.e.
      void setDefaultLocalAddress​(java.net.SocketAddress localAddress)
      Sets the default local address to bind when no argument is specified in bind() method.
      void setDefaultLocalAddresses​(java.lang.Iterable<? extends java.net.SocketAddress> localAddresses)
      Sets the default local addresses to bind when no argument is specified in bind() method.
      void setDefaultLocalAddresses​(java.net.SocketAddress firstLocalAddress, java.net.SocketAddress... otherLocalAddresses)
      Sets the default local addresses to bind when no argument is specified in bind() method.
      void setDefaultLocalAddresses​(java.util.List<? extends java.net.SocketAddress> localAddresses)
      Sets the default local addresses to bind when no argument is specified in bind() method.
      void unbind()
      Unbinds from all local addresses that this service is bound to and stops to accept incoming connections.
      void unbind​(java.lang.Iterable<? extends java.net.SocketAddress> localAddresses)
      Unbinds from the specified local addresses and stop to accept incoming connections.
      void unbind​(java.net.SocketAddress localAddress)
      Unbinds from the specified local address and stop to accept incoming connections.
      void unbind​(java.net.SocketAddress firstLocalAddress, java.net.SocketAddress... otherLocalAddresses)
      Unbinds from the specified local addresses and stop to accept incoming connections.
    • Method Detail

      • getLocalAddress

        java.net.SocketAddress getLocalAddress()
        Returns the local address which is bound currently. If more than one address are bound, only one of them will be returned, but it's not necessarily the firstly bound address.
        Returns:
        The bound LocalAddress
      • getLocalAddresses

        java.util.Set<java.net.SocketAddress> getLocalAddresses()
        Returns a Set of the local addresses which are bound currently.
        Returns:
        The Set of bound LocalAddresses
      • getDefaultLocalAddress

        java.net.SocketAddress getDefaultLocalAddress()
        Returns the default local address to bind when no argument is specified in bind() method. Please note that the default will not be used if any local address is specified. If more than one address are set, only one of them will be returned, but it's not necessarily the firstly specified address in setDefaultLocalAddresses(List).
        Returns:
        The default bound LocalAddress
      • getDefaultLocalAddresses

        java.util.List<java.net.SocketAddress> getDefaultLocalAddresses()
        Returns a List of the default local addresses to bind when no argument is specified in bind() method. Please note that the default will not be used if any local address is specified.
        Returns:
        The list of default bound LocalAddresses
      • setDefaultLocalAddress

        void setDefaultLocalAddress​(java.net.SocketAddress localAddress)
        Sets the default local address to bind when no argument is specified in bind() method. Please note that the default will not be used if any local address is specified.
        Parameters:
        localAddress - The local addresses to bind the acceptor on
      • setDefaultLocalAddresses

        void setDefaultLocalAddresses​(java.net.SocketAddress firstLocalAddress,
                                      java.net.SocketAddress... otherLocalAddresses)
        Sets the default local addresses to bind when no argument is specified in bind() method. Please note that the default will not be used if any local address is specified.
        Parameters:
        firstLocalAddress - The first local address to bind the acceptor on
        otherLocalAddresses - The other local addresses to bind the acceptor on
      • setDefaultLocalAddresses

        void setDefaultLocalAddresses​(java.lang.Iterable<? extends java.net.SocketAddress> localAddresses)
        Sets the default local addresses to bind when no argument is specified in bind() method. Please note that the default will not be used if any local address is specified.
        Parameters:
        localAddresses - The local addresses to bind the acceptor on
      • setDefaultLocalAddresses

        void setDefaultLocalAddresses​(java.util.List<? extends java.net.SocketAddress> localAddresses)
        Sets the default local addresses to bind when no argument is specified in bind() method. Please note that the default will not be used if any local address is specified.
        Parameters:
        localAddresses - The local addresses to bind the acceptor on
      • isCloseOnDeactivation

        boolean isCloseOnDeactivation()
        Returns true if and only if all clients are closed when this acceptor unbinds from all the related local address (i.e. when the service is deactivated).
        Returns:
        true if the service sets the closeOnDeactivation flag
      • setCloseOnDeactivation

        void setCloseOnDeactivation​(boolean closeOnDeactivation)
        Sets whether all client sessions are closed when this acceptor unbinds from all the related local addresses (i.e. when the service is deactivated). The default value is true.
        Parameters:
        closeOnDeactivation - true if we should close on deactivation
      • bind

        void bind()
           throws java.io.IOException
        Binds to the default local address(es) and start to accept incoming connections.
        Throws:
        java.io.IOException - if failed to bind
      • bind

        void bind​(java.net.SocketAddress localAddress)
           throws java.io.IOException
        Binds to the specified local address and start to accept incoming connections.
        Parameters:
        localAddress - The SocketAddress to bind to
        Throws:
        java.io.IOException - if failed to bind
      • bind

        void bind​(java.net.SocketAddress firstLocalAddress,
                  java.net.SocketAddress... addresses)
           throws java.io.IOException
        Binds to the specified local addresses and start to accept incoming connections. If no address is given, bind on the default local address.
        Parameters:
        firstLocalAddress - The first address to bind to
        addresses - The SocketAddresses to bind to
        Throws:
        java.io.IOException - if failed to bind
      • bind

        void bind​(java.net.SocketAddress... addresses)
           throws java.io.IOException
        Binds to the specified local addresses and start to accept incoming connections. If no address is given, bind on the default local address.
        Parameters:
        addresses - The SocketAddresses to bind to
        Throws:
        java.io.IOException - if failed to bind
      • bind

        void bind​(java.lang.Iterable<? extends java.net.SocketAddress> localAddresses)
           throws java.io.IOException
        Binds to the specified local addresses and start to accept incoming connections.
        Parameters:
        localAddresses - The local address we will be bound to
        Throws:
        java.io.IOException - if failed to bind
      • unbind

        void unbind()
        Unbinds from all local addresses that this service is bound to and stops to accept incoming connections. All managed connections will be closed if disconnectOnUnbind property is true. This method returns silently if no local address is bound yet.
      • unbind

        void unbind​(java.net.SocketAddress localAddress)
        Unbinds from the specified local address and stop to accept incoming connections. All managed connections will be closed if disconnectOnUnbind property is true. This method returns silently if the default local address is not bound yet.
        Parameters:
        localAddress - The local address we will be unbound from
      • unbind

        void unbind​(java.net.SocketAddress firstLocalAddress,
                    java.net.SocketAddress... otherLocalAddresses)
        Unbinds from the specified local addresses and stop to accept incoming connections. All managed connections will be closed if disconnectOnUnbind property is true. This method returns silently if the default local addresses are not bound yet.
        Parameters:
        firstLocalAddress - The first local address to be unbound from
        otherLocalAddresses - The other local address to be unbound from
      • unbind

        void unbind​(java.lang.Iterable<? extends java.net.SocketAddress> localAddresses)
        Unbinds from the specified local addresses and stop to accept incoming connections. All managed connections will be closed if disconnectOnUnbind property is true. This method returns silently if the default local addresses are not bound yet.
        Parameters:
        localAddresses - The local address we will be unbound from
      • newSession

        IoSession newSession​(java.net.SocketAddress remoteAddress,
                             java.net.SocketAddress localAddress)
        (Optional) Returns an IoSession that is bound to the specified localAddress and the specified remoteAddress which reuses the local address that is already bound by this service.

        This operation is optional. Please throw UnsupportedOperationException if the transport type doesn't support this operation. This operation is usually implemented for connectionless transport types.

        Parameters:
        remoteAddress - The remote address bound to the service
        localAddress - The local address the session will be bound to
        Returns:
        The session bound to the the given localAddress and remote address
        Throws:
        java.lang.UnsupportedOperationException - if this operation is not supported
        java.lang.IllegalStateException - if this service is not running.
        java.lang.IllegalArgumentException - if this service is not bound to the specified localAddress.