OxL Справочник OxL
РусскийEnglish

method TcpStream.write

Writes all of data.

Example:

oxl✓ проверяется в CI
use std.net { SocketAddr, TcpListener, TcpStream, IpAddr }

fn main() -> () | NetError | ParseError  io, net {
  let l = TcpListener.bind(SocketAddr.parse("127.0.0.1:0")?)?
  defer l.close()?
  let c = TcpStream.connect(l.local, 2s)?
  defer c.close()?
  let s = l.accept(3s)?
  defer s.close()?
  c.write(b"\x01\x02\x03")?
  print("{s.read(16)?}")
}
Вывод
b"\x01\x02\x03"
pub(api) fn write(buf: bytes, timeout: Duration? = none) -> () | NetError  net

Сложность. O(n) in the size of the buffer.

С версии. 1.0.0-beta

Параметры

ИмяТип
bufbytes
timeoutDuration? = none

Возвращает

()

Ошибки

  • NetError
  • `Timeout`, `Unavailable` (the peer closed the connection), `Cancelled`.

Эффекты

net

Определено в: std/net/net.oxl:610

См. также