Class/Object

monix.nio.tcp

TaskSocketChannel

Related Docs: object TaskSocketChannel | package tcp

Permalink

abstract class TaskSocketChannel extends AnyRef

A Task based 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 taskSocketChannel = TaskSocketChannel()
    val writeT =
      for {
        _ <- taskSocketChannel.connect(new InetSocketAddress("google.com", 80))
        written <- taskSocketChannel.write(ByteBuffer.wrap("Hello world!".getBytes("UTF-8")), None)
      } yield {
        written
      }
    writeT.runAsync(new Callback[Int] {
      override def onSuccess(value: Int): Unit = println(f"Bytes written: $value%d")
      override def onError(ex: Throwable): Unit = println(s"ERR: $ex")
    })
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. TaskSocketChannel
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new TaskSocketChannel()

    Permalink

Abstract Value Members

  1. abstract val asyncSocketChannel: AsyncSocketChannel

    Permalink

    The underlying AsyncSocketChannel

    The underlying AsyncSocketChannel

    Attributes
    protected

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 close(): Task[Unit]

    Permalink

    Closes this channel

  7. def connect(remote: InetSocketAddress): Task[Unit]

    Permalink

    Connects this channel.

    Connects this channel.

    remote

    the remote address to which this channel is to be connected

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

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

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

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

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

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

    Permalink
    Definition Classes
    Any
  14. def localAddress(): Task[Option[InetSocketAddress]]

    Permalink

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

  15. final def ne(arg0: AnyRef): Boolean

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

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

    Permalink
    Definition Classes
    AnyRef
  18. def read(dst: ByteBuffer, timeout: Option[Duration] = None): Task[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

  19. def remoteAddress(): Task[Option[InetSocketAddress]]

    Permalink

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

  20. def stopReading(): Task[Unit]

    Permalink

    Indicates that this channel will not read more data

    Indicates that this channel will not read more data

    • end-of-stream indication
  21. def stopWriting(): Task[Unit]

    Permalink

    Indicates that this channel will not write more data

    Indicates that this channel will not write more data

    • end-of-stream indication
  22. final def synchronized[T0](arg0: ⇒ T0): T0

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

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

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  27. def write(src: ByteBuffer, timeout: Option[Duration] = None): Task[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 AnyRef

Inherited from Any

Ungrouped