Interface Connection

    • Method Detail

      • writeMessage

        OutputStream writeMessage()
                           throws IOException
        Write a protocol message. Returns a stream which can be written to, to transmit the data. When the stream is closed, the message is concluded.
        Returns:
        the stream to which the message should be written
        Throws:
        IOException - if an I/O error occurs
      • close

        void close()
            throws IOException
        Close the connection. This will interrupt both reads and writes and so should only be done in the event of an unrecoverable failure of the connection.
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
        Throws:
        IOException - if the close fails
      • setMessageHandler

        void setMessageHandler​(MessageHandler messageHandler)
        Change the current message handler.
        Parameters:
        messageHandler - the new message handler to use
      • getPeerAddress

        InetAddress getPeerAddress()
        Get the remote peer address.
        Returns:
        the peer address
      • attach

        void attach​(Object attachment)
      • getAttachment

        Object getAttachment()
      • backupMessageHandler

        void backupMessageHandler()
        Records the current message handler, which can be reset using restoreMessageHandler()