Class LoadBalancer.SocketHandler

    • Field Detail

      • m_abBuf

        protected byte[] m_abBuf
        The buffer to use for reading from a stream.
    • Constructor Detail

      • SocketHandler

        public SocketHandler​(String sName)
        Construct a SocketHandler with a given daemon thread name.
    • Method Detail

      • run

        public abstract void run()
        Processing loop for the SocketHandler.
        Specified by:
        run in interface Runnable
        Specified by:
        run in class Daemon
      • process

        protected void process​(Socket socketIn,
                               Socket socketOut)
                        throws IOException
        Process the transfer of data from one socket to another.
        Parameters:
        socketIn - the socket to read from
        socketOut - the socket to write to
        Throws:
        IOException
      • copy

        protected void copy​(InputStream streamIn,
                            OutputStream streamOut,
                            byte[] abBuf)
                     throws IOException
        Process the transfer of data from one stream to another.
        Parameters:
        streamIn - the stream to read from
        streamOut - the stream to write to
        abBuf - the byte array to use as a buffer to read into and write from
        Throws:
        IOException
      • ensureBuffer

        protected byte[] ensureBuffer​(Socket socket)
        Return the existing buffer, if there is one, or create one to use for reading from the passed socket.
        Parameters:
        socket - the socket that the buffer will be used to read from
        Returns:
        a byte array to use as a read buffer