Package org.forgerock.opendj.io
Interface RxTransport<M,S extends RxSocket<M>>
-
- Type Parameters:
M
- The type of messages transferred by the transport.S
- The type of reactive sockets exposed by the transport.
- All Superinterfaces:
AutoCloseable
,Closeable
public interface RxTransport<M,S extends RxSocket<M>> extends Closeable
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
close()
Releases any resources, such as thread pools, associated with this transport.Single<S>
connect(String host, int port, Options options)
Returns aSingle
which will connect to the server at the provided address each time it is subscribed.RxServerSocket<M,S>
listen(InetSocketAddress address, Options options)
Starts listening on the provided address and returns anRxServerSocket
which will publish incoming connections via theRxServerSocket.accept()
method.
-
-
-
Method Detail
-
connect
@CheckReturnValue Single<S> connect(String host, int port, Options options)
Returns aSingle
which will connect to the server at the provided address each time it is subscribed. It is the responsibility of the application to enforce timeouts by cancelling the subscription once the timeout is reached. Application layers may return exceptions which are more closely aligned to their APIs. In addition, any initial protocol handshakes should be performed before returning the connected socket.- Parameters:
host
- The hostname of the server to connect to.port
- The port number of the server to connect to.options
- The connection options.- Returns:
- A
Single
which will connect to the server at the provided address each time it is subscribed.
-
listen
@CheckReturnValue RxServerSocket<M,S> listen(InetSocketAddress address, Options options) throws IOException
Starts listening on the provided address and returns anRxServerSocket
which will publish incoming connections via theRxServerSocket.accept()
method. The following example shows how it is possible to listen on multiple addresses:Flowable<S> acceptAll(List<RxServerSocket<M, S>> listeners) { return Flowable.fromIterable(listeners).flatMap(RxServerSocket::accept); }
- Parameters:
address
- The address to listen on.options
- The acceptor options.- Returns:
- An
RxServerSocket
representing the network listener. - Throws:
IOException
- If an error occurred while trying to listen on the provided address.
-
close
default void close()
Releases any resources, such as thread pools, associated with this transport.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
-