|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.knipp.rritoolkit.tcp.TcpChannel
public class TcpChannel
implementation of the RegistryChannel
interface for
SSL TCP connections
Nested Class Summary | |
---|---|
private static class |
TcpChannel.IdleMonitor
class that monitors idle connections and closes them if need be |
Field Summary | |
---|---|
private boolean |
closed
flag whether connection has been closed |
private static int |
connectionCount
the number of connections ever allocated |
private long |
idleCloseTime
the time the connection shall be closed |
private long |
idleTimeout
the idle timeout |
private int |
instanceID
an instance ID |
private java.io.DataInputStream |
inStream
the input stream |
private static long |
MIN_REMAIN_TIME
the minimum time to remain until the channel is reported as closed |
private static TcpChannel.IdleMonitor |
monitor
the thread that closes timed-out channels |
private java.io.DataOutputStream |
outStream
the output stream |
private TcpParams |
params
the parameters |
private static java.util.SortedSet<TcpChannel> |
pendingClose
set of connections that are to be closed |
private java.net.Socket |
socket
the socket |
Constructor Summary | |
---|---|
TcpChannel(TcpParams theParams,
java.net.Socket theSocket)
constructor |
Method Summary | |
---|---|
private static void |
checkMonitor()
check whether the idle monitor has been started. |
void |
close()
close the channel. |
int |
compareTo(TcpChannel obj)
compare this instance with another one. |
boolean |
isClosed()
return whether the channel has been closed |
byte[] |
receive()
wait for a response from the registry. |
void |
send(byte[] data,
boolean isXml)
send the given message to the registry. |
private void |
setCloseTime(long closeTime)
update the close time |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private TcpParams params
private java.net.Socket socket
private final java.io.DataInputStream inStream
private final java.io.DataOutputStream outStream
private boolean closed
private long idleTimeout
private long idleCloseTime
private int instanceID
private static int connectionCount
private static final java.util.SortedSet<TcpChannel> pendingClose
private static TcpChannel.IdleMonitor monitor
private static final long MIN_REMAIN_TIME
Constructor Detail |
---|
public TcpChannel(TcpParams theParams, java.net.Socket theSocket) throws java.io.IOException
theParams
- the parameterstheSocket
- the socket
java.io.IOException
- if the connection could not be establishedMethod Detail |
---|
private static void checkMonitor()
private void setCloseTime(long closeTime)
closeTime
- the new close time, 0
to
disable the automatic closingpublic int compareTo(TcpChannel obj)
idleCloseTime
. If two times are accidentially equal,
the internal instance ID is used for the comparison to make sure that
two instances are only reported as equal if they are identical. Otherwise
the one instance would kick out the other instance in the set.
compareTo
in interface java.lang.Comparable<TcpChannel>
obj
- the other object
-1
if this
instance has an earlier
idleCloseTime
)public void send(byte[] data, boolean isXml) throws java.io.IOException
send
in interface RegistryChannel
data
- the data representing the messageisXml
- true
if the message uses the
XML encoding, false
if the
message uses key-value pairs.
java.io.IOException
- if the transmission failedpublic byte[] receive() throws java.io.IOException
receive
in interface RegistryChannel
java.io.IOException
- if the connection has been closed either
before or during the call.public boolean isClosed()
isClosed
in interface RegistryChannel
true
if closedpublic void close()
close
in interface RegistryChannel
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |