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

method TcpStream.writeText

Writes the UTF-8 bytes of text.

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.writeText("hello")?
  print(s.readText(16)?)
}
Вывод
hello
pub(api) fn writeText(text: str, timeout: Duration? = none) -> () | NetError  net

С версии. 1.0.0-beta

Параметры

ИмяТип
textstr
timeoutDuration? = none

Возвращает

()

Ошибки

Эффекты

net

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

См. также