Class/Object

monix.nio.tcp

AsyncSocketChannel

Related Docs: object AsyncSocketChannel | package tcp

Permalink

abstract class AsyncSocketChannel extends AutoCloseable

An asynchronous channel for reading, writing, and manipulating a TCP socket.

On the JVM this is a wrapper around java.nio.channels.AsynchronousSocketChannel (class available since Java 7 for doing async I/O on sockets).

Example:
  1. val asyncSocketChannel = AsyncSocketChannel()
    val connectF = asyncSocketChannel.connect(new InetSocketAddress("google.com", 80))
    val bytes = ByteBuffer.wrap("Hello world!".getBytes("UTF-8"))
    val writeF = connectF.flatMap(_ => asyncSocketChannel.write(bytes, None))
    writeF.onComplete {
      case Success(nr) =>
        println(f"Bytes written: $nr%d")
     case Failure(exc) =>
        println(s"ERR: $exc")
    }
Linear Supertypes
AutoCloseable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. AsyncSocketChannel
  2. AutoCloseable
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new AsyncSocketChannel()

    Permalink

Abstract Value Members

  1. abstract def close(): Unit

    Permalink
    Definition Classes
    AutoCloseable
    Annotations
    @throws( classOf[java.lang.Exception] )
  2. abstract def connect(remote: InetSocketAddress, cb: Callback[Throwable, Unit]): Unit

    Permalink

    Connects this channel.

    Connects this channel.

    remote

    the remote address to which this channel is to be connected

    cb

    is the callback to be called with the result, once this asynchronous operation is complete

  3. abstract def localAddress(): Option[InetSocketAddress]

    Permalink

    Asks the socket address that this channel's socket is bound to

  4. abstract def read(dst: ByteBuffer, cb: Callback[Throwable, Int], timeout: Option[Duration] = None): Unit

    Permalink

    Reads a sequence of bytes from this channel into the given buffer

    Reads a sequence of bytes from this channel into the given buffer

    dst

    is the buffer holding the bytes read on completion

    cb

    is the callback to be called with the result, once this asynchronous operation is complete . For this method it signals the number of bytes read or -1 if no bytes could be read because the channel has reached end-of-stream

    timeout

    an optional maximum time for the I/O operation to complete

  5. abstract def remoteAddress(): Option[InetSocketAddress]

    Permalink

    Asks the remote address to which this channel's socket is connected

  6. abstract def stopReading(): Unit

    Permalink

    Indicates that this channel will not read more data

    Indicates that this channel will not read more data

    • end-of-stream indication
  7. abstract def stopWriting(): Unit

    Permalink

    Indicates that this channel will not write more data

    Indicates that this channel will not write more data

    • end-of-stream indication
  8. abstract def write(src: ByteBuffer, cb: Callback[Throwable, Int], timeout: Option[Duration] = None): Unit

    Permalink

    Writes a sequence of bytes to this channel from the given buffer

    Writes a sequence of bytes to this channel from the given buffer

    src

    is the buffer holding the sequence of bytes to write

    cb

    is the callback to be called with the result, once this asynchronous operation is complete . For this method it signals the number of bytes that were written

    timeout

    an optional maximum time for the I/O operation to complete

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. def connect(remote: InetSocketAddress): Future[Unit]

    Permalink

    Connects this channel.

    Connects this channel.

    remote

    the remote address to which this channel is to be connected

  7. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  8. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  9. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  11. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  12. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  13. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  14. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  15. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  16. def read(dst: ByteBuffer, timeout: Option[Duration]): Future[Int]

    Permalink

    Reads a sequence of bytes from this channel into the given buffer

    Reads a sequence of bytes from this channel into the given buffer

    dst

    is the buffer holding the bytes read on completion

    timeout

    an optional maximum time for the I/O operation to complete

    returns

    the number of bytes read or -1 if no bytes could be read because the channel has reached end-of-stream

  17. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  18. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  19. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  20. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  21. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  22. def write(src: ByteBuffer, timeout: Option[Duration]): Future[Int]

    Permalink

    Writes a sequence of bytes to this channel from the given buffer

    Writes a sequence of bytes to this channel from the given buffer

    src

    is the buffer holding the sequence of bytes to write

    timeout

    an optional maximum time for the I/O operation to complete

    returns

    the number of bytes that were written

Inherited from AutoCloseable

Inherited from AnyRef

Inherited from Any

Ungrouped