|
|
|
|
|
by Matthias247
1469 days ago
|
|
Same as the synchronous version: It will block until more data can be written, and then go on and write as much as possible using another async .write() call. It's the same as: let mut offset = 0;
while offset != number_as_bytes.length() {
let written = stream.write(&number_as_bytes[offset..]).await.unwrap();
offset += written;
}
The synchronous version would be the same without the .await, and offers stronger guarantees that either all bytes are written to the socket or the socket errored and is dead. The async version could be cancelled in the middle of the invocation after some segments have already been written. |
|