An asynchronous channel for stream-oriented listening sockets.
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).
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") }
An asynchronous channel for reading, writing, and manipulating a TCP socket.
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).
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") }
A TCP client composed of an async reader(AsyncSocketChannelObservable) and an async writer(AsyncSocketChannelConsumer) pair that both use the same underlying socket that is not released automatically.
A TCP client composed of an async reader(AsyncSocketChannelObservable) and an async writer(AsyncSocketChannelConsumer) pair that both use the same underlying socket that is not released automatically.
In order to release the connection use close()
A TCP socket Consumer that can be used to send data asynchronously from an Observable.
A TCP socket Consumer that can be used to send data asynchronously from an Observable. The underlying socket will be closed when the Observable ends
A TCP socket Observable that can be subscribed to in order to read the incoming bytes asynchronously.
A TCP socket Observable that can be subscribed to
in order to read the incoming bytes asynchronously.
The underlying socket is closed on end-of-stream
, on signalling Stop
after subscription or by cancelling it directly
A Task
based asynchronous channel for stream-oriented listening sockets.
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).
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") })
A Task
based asynchronous channel for reading, writing, and manipulating a TCP socket.
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).
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") })
Creates a TCP server
Creates a TCP server
hostname
TCP port number
a bound TaskServerSocketChannel
Returns a TCP socket Observable that can be subscribed to in order to read the incoming bytes asynchronously.
Returns a TCP socket Observable that can be subscribed to in order to read the incoming bytes asynchronously. It will close the socket on end-of-stream, signalling Stop after subscription or by cancelling it directly
the underlying TaskSocketChannel
the size of the buffer used for reading
Returns a TCP socket Observable that can be subscribed to in order to read the incoming bytes asynchronously.
Returns a TCP socket Observable that can be subscribed to in order to read the incoming bytes asynchronously. It will close the socket on end-of-stream, signalling Stop after subscription or by cancelling it directly
hostname
TCP port number
the size of the buffer used for reading
Creates a TCP client - an async reader(AsyncSocketChannelObservable) and an async writer(AsyncSocketChannelConsumer) pair that both use the same underlying socket that is not released automatically.
Creates a TCP client - an async reader(AsyncSocketChannelObservable) and an async writer(AsyncSocketChannelConsumer) pair that both use the same underlying socket that is not released automatically.
In order to release the connection use close()
the underlying TaskSocketChannel
the size of the buffer used for reading
Creates a TCP client - an async reader(AsyncSocketChannelObservable) and an async writer(AsyncSocketChannelConsumer) pair that both use the same underlying socket that is not released automatically.
Creates a TCP client - an async reader(AsyncSocketChannelObservable) and an async writer(AsyncSocketChannelConsumer) pair that both use the same underlying socket that is not released automatically.
In order to release the connection use close()
hostname
TCP port number
the size of the buffer used for reading
Returns a TCP socket Consumer that can be used to send data asynchronously from an Observable.
Returns a TCP socket Consumer that can be used to send data asynchronously from an Observable. The underlying socket will be closed when the Observable ends
the underlying TaskSocketChannel
Returns a TCP socket Consumer that can be used to send data asynchronously from an Observable.
Returns a TCP socket Consumer that can be used to send data asynchronously from an Observable. The underlying socket will be closed when the Observable ends
hostname
TCP port number