Class ChannelIO

java.lang.Object
jp.cssj.driver.ctip.common.ChannelIO

public final class ChannelIO extends Object
Nonblocking channel operations and deadline-based waits.
  • Field Details

    • MAX_STRING_BYTES

      public static final int MAX_STRING_BYTES
      文字列1つの上限(長さは符号なし16bitで送るため)。
      See Also:
  • Constructor Details

  • Method Details

    • getChannel

      public ByteChannel getChannel()
    • getSelectable

      public SelectableChannel getSelectable()
    • close

      public void close() throws IOException
      Throws:
      IOException
    • wakeup

      public void wakeup()
    • deadline

      public static long deadline(long timeout)
    • checkDeadline

      public static void checkDeadline(long deadline) throws SocketTimeoutException
      Throws:
      SocketTimeoutException
    • deadline

      public long deadline()
    • awaitReady

      public static void awaitReady(SelectableChannel channel, int ops, long deadline) throws IOException
      Also used before ChannelIO exists (TCP/TLS connect) and after it closes (TLS shutdown).
      Throws:
      IOException
    • await

      public void await(int ops, long deadline) throws IOException
      Each waiter owns its selector: a concurrent abort never waits for the reader's monitor.
      Throws:
      IOException
    • readSome

      public int readSome(ByteBuffer dest) throws IOException
      Throws:
      IOException
    • writeSome

      public int writeSome(ByteBuffer src) throws IOException
      Throws:
      IOException
    • flushOutbound

      public boolean flushOutbound() throws IOException
      Throws:
      IOException
    • hasPendingOutbound

      public boolean hasPendingOutbound()
    • hasPlaintext

      public boolean hasPlaintext()
    • readOps

      public int readOps()
    • writeOps

      public int writeOps()
    • rwselect

      public SelectionKey rwselect() throws IOException
      Legacy v1 readiness API. v2 uses internal progress before await().
      Throws:
      IOException
    • readAll

      public void readAll(ByteBuffer dest) throws IOException
      Throws:
      IOException
    • writeAll

      public void writeAll(ByteBuffer src) throws IOException
      Throws:
      IOException
    • readByte

      public byte readByte(ByteBuffer destByte) throws IOException
      1バイト整数を読み込みます。
      Parameters:
      destByte -
      Returns:
      読み込んだ値。
      Throws:
      IOException
    • readShort

      public short readShort(ByteBuffer destShort) throws IOException
      2バイト整数を読み込みます。
      Parameters:
      destShort -
      Returns:
      読み込んだ値。
      Throws:
      IOException
    • readInt

      public int readInt(ByteBuffer destInt) throws IOException
      4バイト整数を読み込みます。
      Parameters:
      destInt -
      Returns:
      読み込んだ値。
      Throws:
      IOException
    • readLong

      public long readLong(ByteBuffer destLong) throws IOException
      8バイト整数を読み込みます。
      Parameters:
      destLong -
      Returns:
      読み込んだ値。
      Throws:
      IOException
    • readString

      public String readString(ByteBuffer destShort, String encoding) throws IOException
      文字列を読み込みます。 文字列は2バイトの文字列長(バイト数)に続く文字列本体のバイト列で構成されます。 バイト列は指定したエンコーディングで文字列に変換します。
      Parameters:
      destShort -
      encoding -
      Returns:
      読み込んだ文字列。
      Throws:
      IOException
    • readBytes

      public byte[] readBytes(int len) throws IOException
      指定された長さだけバイト列を読み込みます。
      Parameters:
      len -
      Returns:
      読み込んだデータ。
      Throws:
      IOException
    • toBytes

      public static byte[] toBytes(String str, String encoding) throws IOException
      Throws:
      IOException