Class/Object

monix.nio.tcp

AsyncServerSocketChannel

Related Docs: object AsyncServerSocketChannel | package tcp

Permalink

abstract class AsyncServerSocketChannel extends AutoCloseable

An asynchronous channel for stream-oriented listening sockets.

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

Example:
  1. val server = AsyncServerSocketChannel()
    server.bind(new InetSocketAddress(InetAddress.getByName(null), 9000))
    val bytes = ByteBuffer.wrap("Hello world!".getBytes("UTF-8"))
    val writeF = server
      .accept()
      .flatMap { conn =>
        val writeF0 = conn.write(bytes, None)
        conn.stopWriting()
        writeF0
      }
      .map { sentLen =>
         server.close()
         sentLen
      }
    writeF.onComplete {
      case Success(nr) =>
        println(f"Bytes sent: $nr%d")
      case Failure(exc) =>
        println(s"ERR: $exc")
    }
Linear Supertypes
AutoCloseable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. AsyncServerSocketChannel
  2. AutoCloseable
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new AsyncServerSocketChannel()

    Permalink

Abstract Value Members

  1. abstract def accept(cb: Callback[Throwable, AsyncSocketChannel]): Unit

    Permalink

    Accepts a connection

    Accepts a connection

    cb

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

  2. abstract def bind(local: InetSocketAddress, backlog: Int = 0): Unit

    Permalink

    Binds the channel's socket to a local address and configures the socket to listen for connections

    Binds the channel's socket to a local address and configures the socket to listen for connections

    local

    the local address to bind the socket, or null to bind to an automatically assigned socket address

    backlog

    the maximum number of pending connections. If the backlog parameter has the value 0, or a negative value, then an implementation specific default is used.

  3. abstract def close(): Unit

    Permalink
    Definition Classes
    AutoCloseable
    Annotations
    @throws( classOf[java.lang.Exception] )
  4. abstract def localAddress(): Option[InetSocketAddress]

    Permalink

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

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. def accept(): Future[AsyncSocketChannel]

    Permalink

    Accepts a connection

  5. final def asInstanceOf[T0]: T0

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

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  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. final def synchronized[T0](arg0: ⇒ T0): T0

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

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

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AutoCloseable

Inherited from AnyRef

Inherited from Any

Ungrouped