Class TcpProxy

java.lang.Object
org.netxms.client.TcpProxy

public class TcpProxy extends Object
TCP proxy object
  • Constructor Details

    • TcpProxy

      protected TcpProxy(NXCSession session, int channelId) throws IOException
      Create new TCP proxy object.
      Parameters:
      session - underlying NetXMS client session
      channelId - proxy channel ID
      Throws:
      IOException - when input or output stream cannot be created
  • Method Details

    • close

      public void close()
      Close proxy session. Calling this method will also close both input and output streams.
    • localClose

      protected void localClose()
      Close local resources associated with proxy session. Should only be called by remote proxy session closure notification handler.
    • abort

      protected void abort(Throwable cause)
      Abort TCP proxy session due to external error. Next attempt to read from this proxy input stream will throw IOException.
      Parameters:
      cause - cause for abort
    • isClosed

      public boolean isClosed()
      Check if proxy session is closed.
      Returns:
      true if proxy session is closed
    • getInputStream

      public InputStream getInputStream()
      Get input stream for this TCP proxy.
      Returns:
      input stream for this TCP proxy
    • getOutputStream

      public OutputStream getOutputStream()
      Get output stream for this TCP proxy.
      Returns:
      output stream for this TCP proxy
    • getChannelId

      protected int getChannelId()
      Get channel ID
      Returns:
      channel ID
    • getFlushException

      public Exception getFlushException()
      Get last exception generated when flushing output buffer.
      Returns:
      last exception generated when flushing output buffer or null
    • getSizeThreshold

      public int getSizeThreshold()
      Get current size threshold.
      Returns:
      current size threshold
    • getTimeThreshold

      public int getTimeThreshold()
      Get current time threshold.
      Returns:
      current time threshold
    • setBufferingThresholds

      public void setBufferingThresholds(int sizeThreshold, int timeThreshold)
      Set write buffering thresholds. If these parameters are non-zero, proxy object will buffer outgoing data until it reach size threshold, but not longer that time threshold.
      Parameters:
      sizeThreshold - data size threshold in bytes
      timeThreshold - time threshold in milliseconds
    • send

      public void send(byte[] data) throws IOException, NXCException
      Send data to destination
      Parameters:
      data - data block
      Throws:
      IOException - when client cannot send data to the server or channel is already closed
      NXCException - when NetXMS server cannot accept or forward data
    • processRemoteData

      protected void processRemoteData(byte[] data)
      Process data received from remote end
      Parameters:
      data - data received