Class UDPNIOTransport

    • Constructor Detail

      • UDPNIOTransport

        public UDPNIOTransport()
      • UDPNIOTransport

        public UDPNIOTransport​(java.lang.String name)
    • Method Detail

      • addShutdownListener

        public boolean addShutdownListener​(GracefulShutdownListener shutdownListener)
        Description copied from interface: Transport
        Adds a GracefulShutdownListener which will be called when Transport.shutdown() is called to enable graceful shutdown of transports. This allows the owner of the listener to signal that all shutdown tasks are complete and that it's safe to finalize the termination of the transport
        Specified by:
        addShutdownListener in interface Transport
        Overrides:
        addShutdownListener in class NIOTransport
        Parameters:
        shutdownListener - the GracefulShutdownListener
        Returns:
        true if the listener was successfully registered, otherwise false. When this method returns false it means one of two things: the transport is stopping or is stopped, or the listener has already been registered.
      • bind

        public UDPNIOServerConnection bind​(int port)
                                    throws java.io.IOException
        Binds Transport to the specific port on localhost.
        Specified by:
        bind in interface SocketBinder
        Parameters:
        port - the port to bind to
        Returns:
        bound Connection
        Throws:
        java.io.IOException - if unable to bind i.e. if port already bound
      • bind

        public UDPNIOServerConnection bind​(java.lang.String host,
                                           int port)
                                    throws java.io.IOException
        Binds Transport to the specific host and port.
        Specified by:
        bind in interface SocketBinder
        Parameters:
        host - the local host the server will bind to
        port - specific port to bind to
        Returns:
        bound Connection
        Throws:
        java.io.IOException - if unable to bind i.e. if port already bound
      • bind

        public UDPNIOServerConnection bind​(java.lang.String host,
                                           int port,
                                           int backlog)
                                    throws java.io.IOException
        Binds Transport to the specific host and port.
        Specified by:
        bind in interface SocketBinder
        Parameters:
        host - the local host the server will bind to
        port - the port to bind to
        backlog - the maximum length of the queue
        Returns:
        bound Connection
        Throws:
        java.io.IOException - if unable to bind i.e. if port already bound
      • bind

        public UDPNIOServerConnection bind​(java.net.SocketAddress socketAddress)
                                    throws java.io.IOException
        Binds Transport to the specific SocketAddress.
        Specified by:
        bind in interface SocketBinder
        Parameters:
        socketAddress - the local address the server will bind to
        Returns:
        bound Connection
        Throws:
        java.io.IOException - if unable to bind i.e. if port already bound
      • bind

        public UDPNIOServerConnection bind​(java.net.SocketAddress socketAddress,
                                           int backlog)
                                    throws java.io.IOException
        Binds Transport to the specific SocketAddress.
        Specified by:
        bind in interface SocketBinder
        Parameters:
        socketAddress - the local address the server will bind to
        backlog - the maximum length of the queue
        Returns:
        bound Connection
        Throws:
        java.io.IOException - if unable to bind i.e. if port already bound
      • bindToInherited

        public Connection<?> bindToInherited()
                                      throws java.io.IOException
        Description copied from interface: SocketBinder
        Binds the Transport to the channel inherited from the entity that created this Java virtual machine.
        Specified by:
        bindToInherited in interface SocketBinder
        Returns:
        bound Connection
        Throws:
        java.io.IOException - if unable to bind i.e. if port already bound
      • bind

        public UDPNIOServerConnection bind​(java.lang.String host,
                                           PortRange portRange,
                                           int backlog)
                                    throws java.io.IOException
        Binds Transport to the specific host, and port within a PortRange.
        Specified by:
        bind in interface SocketBinder
        Parameters:
        host - the local host the server will bind to
        portRange - PortRange.
        backlog - the maximum length of the queue
        Returns:
        bound Connection
        Throws:
        java.io.IOException - if unable to bind i.e. if port already bound
      • bind

        public UDPNIOServerConnection bind​(java.lang.String host,
                                           PortRange portRange,
                                           boolean randomStartPort,
                                           int backlog)
                                    throws java.io.IOException
        Binds Transport to the specific host, and port within a PortRange.
        Specified by:
        bind in interface SocketBinder
        Parameters:
        host - the local host the server will bind to
        portRange - PortRange.
        randomStartPort - if true, a random port in the range will be used as the initial port.
        backlog - the maximum length of the queue
        Returns:
        bound Connection
        Throws:
        java.io.IOException - if unable to bind i.e. if port already bound
      • connect

        public GrizzlyFuture<Connection> connect​(java.lang.String host,
                                                 int port)
                                          throws java.io.IOException
        Creates, initializes and connects socket to the specific remote host and port and returns Connection, representing socket.
        Specified by:
        connect in interface SocketConnectorHandler
        Parameters:
        host - remote host to connect to.
        port - remote port to connect to.
        Returns:
        GrizzlyFuture of connect operation, which could be used to get resulting Connection.
        Throws:
        java.io.IOException
      • connect

        public GrizzlyFuture<Connection> connect​(java.net.SocketAddress remoteAddress)
        Creates, initializes and connects socket to the specific SocketAddress and returns Connection, representing socket.
        Specified by:
        connect in interface ConnectorHandler<java.net.SocketAddress>
        Parameters:
        remoteAddress - remote address to connect to.
        Returns:
        GrizzlyFuture of connect operation, which could be used to get resulting Connection.
        Throws:
        java.io.IOException
      • connect

        public void connect​(java.net.SocketAddress remoteAddress,
                            CompletionHandler<Connection> completionHandler)
        Creates, initializes and connects socket to the specific SocketAddress and returns Connection, representing socket.
        Specified by:
        connect in interface ConnectorHandler<java.net.SocketAddress>
        Parameters:
        remoteAddress - remote address to connect to.
        completionHandler - CompletionHandler.
      • connect

        public GrizzlyFuture<Connection> connect​(java.net.SocketAddress remoteAddress,
                                                 java.net.SocketAddress localAddress)
        Creates, initializes socket, binds it to the specific local and remote SocketAddress and returns Connection, representing socket.
        Specified by:
        connect in interface ConnectorHandler<java.net.SocketAddress>
        Parameters:
        remoteAddress - remote address to connect to.
        localAddress - local address to bind socket to.
        Returns:
        GrizzlyFuture of connect operation, which could be used to get resulting Connection.
      • connect

        public void connect​(java.net.SocketAddress remoteAddress,
                            java.net.SocketAddress localAddress,
                            CompletionHandler<Connection> completionHandler)
        Creates, initializes socket, binds it to the specific local and remote SocketAddress and returns Connection, representing socket.
        Specified by:
        connect in interface ConnectorHandler<java.net.SocketAddress>
        Parameters:
        remoteAddress - remote address to connect to.
        localAddress - local address to bind socket to.
        completionHandler - CompletionHandler.
      • closeConnection

        protected void closeConnection​(Connection connection)
                                throws java.io.IOException
        Description copied from class: AbstractTransport
        Close the connection, managed by Transport
        Specified by:
        closeConnection in class NIOTransport
        Parameters:
        connection - NIOConnection to close
        Throws:
        java.io.IOException - not used
      • configureStandalone

        public void configureStandalone​(boolean isStandalone)
        Specified by:
        configureStandalone in interface Transport
      • getReader

        public Reader getReader​(boolean isBlocking)
        Get the Reader implementation, depending on the requested mode.
        Specified by:
        getReader in interface Transport
        Parameters:
        isBlocking - blocking mode.
        Returns:
        Reader.
      • getWriter

        public Writer getWriter​(boolean isBlocking)
        Get the Writer implementation, depending on the requested mode.
        Specified by:
        getWriter in interface Transport
        Parameters:
        isBlocking - blocking mode.
        Returns:
        Writer.
      • read

        public int read​(UDPNIOConnection connection,
                        Buffer buffer)
                 throws java.io.IOException
        Throws:
        java.io.IOException
      • write

        public long write​(UDPNIOConnection connection,
                          java.net.SocketAddress dstAddress,
                          WritableMessage message)
                   throws java.io.IOException
        Throws:
        java.io.IOException
      • createJmxManagementObject

        protected java.lang.Object createJmxManagementObject()
        Create the Transport JMX management object.
        Specified by:
        createJmxManagementObject in class AbstractTransport
        Returns:
        the Transport JMX management object.