The server prepares by fullfillling the connectionEstablished promise, which contains a callback that allwows any number of clients to connect. The inner callback contains the Connection the server sends on, as well as a promise that the server completes immediately with it’s own receive handler.
The returned async, when run, should establish connections with the given callback atomically. That is, no messages should be lost during setup. Similarly, the provider of the callback (the result of incoming) of this method should make sure that the other end of the callback is ready to receive callbacks before running the async.
The returned async, when run, should establish connections with the given callback atomically. That is, no messages should be lost during setup. Similarly, the provider of the callback (the result of incoming) of this method should make sure that the other end of the callback is ready to receive callbacks before running the async.
It is generally not assumed to be safe to run prepare twice (neither running a single async twice, nor running two different returned asyncs). Notably, “server” like implementations may try to bind a specific port, and immediately fail if that is not available.
The async may produce multiple connections and will run incomingHandler for each of them.