Class TCPNIOTransport

    • Field Detail

      • MAX_RECEIVE_BUFFER_SIZE

        public static final int MAX_RECEIVE_BUFFER_SIZE
      • MAX_SEND_BUFFER_SIZE

        public static final int MAX_SEND_BUFFER_SIZE
      • DEFAULT_SERVER_CONNECTION_BACKLOG

        public static final int DEFAULT_SERVER_CONNECTION_BACKLOG
        See Also:
        Constant Field Values
    • Constructor Detail

      • TCPNIOTransport

        public TCPNIOTransport()
    • Method Detail

      • bind

        public TCPNIOServerConnection 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 TCPNIOServerConnection 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 TCPNIOServerConnection 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 TCPNIOServerConnection 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 TCPNIOServerConnection 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 TCPNIOServerConnection bindToInherited()
                                               throws java.io.IOException
        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 TCPNIOServerConnection 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 TCPNIOServerConnection 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)
        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.
      • 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.
      • 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
      • getLinger

        public int getLinger()
      • setLinger

        public void setLinger​(int linger)
      • isKeepAlive

        public boolean isKeepAlive()
      • setKeepAlive

        public void setKeepAlive​(boolean isKeepAlive)
      • isTcpNoDelay

        public boolean isTcpNoDelay()
      • setTcpNoDelay

        public void setTcpNoDelay​(boolean tcpNoDelay)
      • getServerConnectionBackLog

        public int getServerConnectionBackLog()
        Get the default server connection backlog size.
        Returns:
        the default server connection backlog size.
      • setServerConnectionBackLog

        public void setServerConnectionBackLog​(int serverConnectionBackLog)
        Set the default server connection backlog size.
        Parameters:
        serverConnectionBackLog - the default server connection backlog size.
      • getReader

        public Reader<java.net.SocketAddress> 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<java.net.SocketAddress> 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 Buffer read​(Connection connection,
                           Buffer buffer)
                    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.