OxL Reference

method TcpStream.write

Writes all of data.

Example:

oxl✓ checked in 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)?}")
}
Output
b"\x01\x02\x03"
pub(api) fn write(buf: bytes, timeout: Duration? = none) -> () | NetError  net

Complexity. O(n) in the size of the buffer.

Since. 1.0.0-beta

Parameters

NameType
bufbytes
timeoutDuration? = none

Returns

()

Errors

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

Effects

net

Defined in: std/net/net.oxl:610

See also