Package org.netxms.client
Class TcpProxy
java.lang.Object
org.netxms.client.TcpProxy
TCP proxy object
-
Constructor Summary
ModifierConstructorDescriptionprotected
TcpProxy
(NXCSession session, int channelId) Create new TCP proxy object. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Abort TCP proxy session due to external error.void
close()
Close proxy session.protected int
Get channel IDGet last exception generated when flushing output buffer.Get input stream for this TCP proxy.Get output stream for this TCP proxy.int
Get current size threshold.int
Get current time threshold.boolean
isClosed()
Check if proxy session is closed.protected void
Close local resources associated with proxy session.protected void
processRemoteData
(byte[] data) Process data received from remote endvoid
send
(byte[] data) Send data to destinationvoid
setBufferingThresholds
(int sizeThreshold, int timeThreshold) Set write buffering thresholds.
-
Constructor Details
-
TcpProxy
Create new TCP proxy object.- Parameters:
session
- underlying NetXMS client sessionchannelId
- 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
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
Get input stream for this TCP proxy.- Returns:
- input stream for this TCP proxy
-
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
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 bytestimeThreshold
- time threshold in milliseconds
-
send
Send data to destination- Parameters:
data
- data block- Throws:
IOException
- when client cannot send data to the server or channel is already closedNXCException
- when NetXMS server cannot accept or forward data
-
processRemoteData
protected void processRemoteData(byte[] data) Process data received from remote end- Parameters:
data
- data received
-