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
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") }- Companion
- object
Value members
Abstract methods
Accepts a connection
Accepts a connection
- Value Params
- cb
is the callback to be called with the result, once this asynchronous operation is complete
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