method TcpStream.writeText
Writes the UTF-8 bytes of text.
Example:
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)?)
}Output
hello
pub(api) fn writeText(text: str, timeout: Duration? = none) -> () | NetError netSince. 1.0.0-beta
Parameters
| Name | Type |
|---|---|
text | str |
timeout | Duration? = none |
Returns
()
Errors
NetError- those of `write`.
Effects
net
Defined in: std/net/net.oxl:636