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
Fields -
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) 1バイト整数を読み込みます。byte[]readBytes(int len) 指定された長さだけバイト列を読み込みます。intreadInt(ByteBuffer destInt) 4バイト整数を読み込みます。longreadLong(ByteBuffer destLong) 8バイト整数を読み込みます。intreadOps()shortreadShort(ByteBuffer destShort) 2バイト整数を読み込みます。intreadSome(ByteBuffer dest) readString(ByteBuffer destShort, String encoding) 文字列を読み込みます。 文字列は2バイトの文字列長(バイト数)に続く文字列本体のバイト列で構成されます。 バイト列は指定したエンコーディングで文字列に変換します。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_BYTES文字列1つの上限(長さは符号なし16bitで送るため)。- 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
1バイト整数を読み込みます。- Parameters:
destByte-- Returns:
- 読み込んだ値。
- Throws:
IOException
-
readShort
2バイト整数を読み込みます。- Parameters:
destShort-- Returns:
- 読み込んだ値。
- Throws:
IOException
-
readInt
4バイト整数を読み込みます。- Parameters:
destInt-- Returns:
- 読み込んだ値。
- Throws:
IOException
-
readLong
8バイト整数を読み込みます。- Parameters:
destLong-- Returns:
- 読み込んだ値。
- Throws:
IOException
-
readString
文字列を読み込みます。 文字列は2バイトの文字列長(バイト数)に続く文字列本体のバイト列で構成されます。 バイト列は指定したエンコーディングで文字列に変換します。- Parameters:
destShort-encoding-- Returns:
- 読み込んだ文字列。
- Throws:
IOException
-
readBytes
指定された長さだけバイト列を読み込みます。- Parameters:
len-- Returns:
- 読み込んだデータ。
- Throws:
IOException
-
toBytes
- Throws:
IOException
-