TaskServerSocketChannel

A Task based 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
 val server = TaskServerSocketChannel()
 val writeT = for {
   _ <- server.bind(new InetSocketAddress(InetAddress.getByName(null), 9000))
   conn <- server.accept()
   written <- conn.writeL(java.nio.ByteBuffer.wrap("Hello world!".getBytes))
   _ <- Task.eval(conn.stopWriting())
   _ <- server.close()
 } yield {
   written
 }
 writeT.runAsync(new Callback[Int] {
   override def onError(ex: Throwable) = println(ex)
   override def onSuccess(value: Int) = println(f"Bytes sent: $value%d")
 })
Companion
object
class Object
trait Matchable
class Any

Value members

Concrete methods

Accepts a connection

Accepts a connection

def bind(local: InetSocketAddress, backlog: Int): Task[Unit]

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

Value Params
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.

local

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

def close(): Task[Unit]

Closes this channel

Closes this channel

def localAddress(): Task[Option[InetSocketAddress]]

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

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