Package jp.cssj.driver.ctip.common
Class ChannelIO
java.lang.Object
jp.cssj.driver.ctip.common.ChannelIO
Nonblocking channel operations and deadline-based waits.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe limit for one string (its length is sent as an unsigned 16-bit value). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidawait(int ops, long deadline) Each waiter owns its selector: a concurrent abort never waits for the reader's monitor.static voidawaitReady(SelectableChannel channel, int ops, long deadline) Also used before ChannelIO exists (TCP/TLS connect) and after it closes (TLS shutdown).static voidcheckDeadline(long deadline) voidclose()longdeadline()static longdeadline(long timeout) booleanbooleanbooleanvoidreadAll(ByteBuffer dest) bytereadByte(ByteBuffer destByte) Reads a 1-byte integer.byte[]readBytes(int len) Reads the specified number of bytes.intreadInt(ByteBuffer destInt) Reads a 4-byte integer.longreadLong(ByteBuffer destLong) Reads an 8-byte integer.intreadOps()shortreadShort(ByteBuffer destShort) Reads a 2-byte integer.intreadSome(ByteBuffer dest) readString(ByteBuffer destShort, String encoding) Reads a string: a 2-byte length (in bytes) followed by the bytes of the string itself.rwselect()Legacy v1 readiness API.static byte[]voidwakeup()voidwriteAll(ByteBuffer src) intwriteOps()intwriteSome(ByteBuffer src)
-
Field Details
-
MAX_STRING_BYTES
public static final int MAX_STRING_BYTESThe limit for one string (its length is sent as an unsigned 16-bit value).- See Also:
-
-
Constructor Details
-
ChannelIO
- Throws:
IOException
-
-
Method Details
-
getChannel
-
getSelectable
-
close
- Throws:
IOException
-
wakeup
public void wakeup() -
deadline
public static long deadline(long timeout) -
checkDeadline
- Throws:
SocketTimeoutException
-
deadline
public long deadline() -
awaitReady
Also used before ChannelIO exists (TCP/TLS connect) and after it closes (TLS shutdown).- Throws:
IOException
-
await
Each waiter owns its selector: a concurrent abort never waits for the reader's monitor.- Throws:
IOException
-
readSome
- Throws:
IOException
-
writeSome
- Throws:
IOException
-
flushOutbound
- Throws:
IOException
-
hasPendingOutbound
public boolean hasPendingOutbound() -
hasPlaintext
public boolean hasPlaintext() -
readOps
public int readOps() -
writeOps
public int writeOps() -
rwselect
Legacy v1 readiness API. v2 uses internal progress before await().- Throws:
IOException
-
readAll
- Throws:
IOException
-
writeAll
- Throws:
IOException
-
readByte
Reads a 1-byte integer.- Parameters:
destByte-- Returns:
- The value read.
- Throws:
IOException
-
readShort
Reads a 2-byte integer.- Parameters:
destShort-- Returns:
- The value read.
- Throws:
IOException
-
readInt
Reads a 4-byte integer.- Parameters:
destInt-- Returns:
- The value read.
- Throws:
IOException
-
readLong
Reads an 8-byte integer.- Parameters:
destLong-- Returns:
- The value read.
- Throws:
IOException
-
readString
Reads a string: a 2-byte length (in bytes) followed by the bytes of the string itself. Converts the bytes to a string using the specified encoding.- Parameters:
destShort-encoding-- Returns:
- The string read.
- Throws:
IOException
-
readBytes
Reads the specified number of bytes.- Parameters:
len-- Returns:
- The data read.
- Throws:
IOException
-
toBytes
- Throws:
IOException
-