Stream.writeAsync() Overload 1

DESCRIPTION

Write data on a stream asynchronously.

When the closure is invoked with an indication of success, the data is only written to the stream, but not necessarily acknowledged by the receiver. This is why it does not make sense to return a number of actual bytes written in case of error since it says nothing about the number of acked bytes. To ensure that written bytes have been acked, a successful call to Stream.close() is necessary after last call to this Stream.write().

DECLARATION

    public func writeAsync(data: Data, closure: @escaping AsyncStatusReceiver) 

PARAMETERS

data:
the data to write
closure:
Invoked when the operation completes, see synchronous write() for possible errors.

Overload 2

DESCRIPTION

Write data on a stream asynchronously.

When the call returns, the data is only written to the stream, but not necessarily acknowledged by the receiver. This is why it does not make sense to return a number of actual bytes written in case of error since it says nothing about the number of acked bytes. To ensure that written bytes have been acked, a successful call to Stream.close() is necessary after last call to this Stream.write().

DECLARATION

    public func writeAsync(data: Data) async throws 

PARAMETERS

data:
the data to write

THROWS ERRORS

STOPPED:
if the stream has been closed
OPERATION_IN_PROGRESS:
if another write operation is already in progress