MCPcopy Create free account
hub / github.com/bytecodealliance/wstd / main

Function main

examples/tcp_stream_client.rs:5–25  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3
4#[wstd::main]
5async fn main() -> io::Result<()> {
6 let mut args = std::env::args();
7
8 let _ = args.next();
9
10 let addr = args.next().ok_or_else(|| {
11 io::Error::new(
12 std::io::ErrorKind::InvalidInput,
13 "address argument required",
14 )
15 })?;
16
17 let mut stream = TcpStream::connect(addr).await?;
18
19 stream.write_all(b"ping\n").await?;
20
21 let mut reply = Vec::new();
22 stream.read_to_end(&mut reply).await?;
23
24 Ok(())
25}

Callers

nothing calls this directly

Calls 3

nextMethod · 0.45
write_allMethod · 0.45
read_to_endMethod · 0.45

Tested by

no test coverage detected