16 lines
353 B
Rust
16 lines
353 B
Rust
use tokio::net::TcpStream;
|
|
use tokio::io::{AsyncWriteExt};
|
|
use std::error::Error;
|
|
|
|
|
|
#[tokio::main]
|
|
async fn main() -> Result<(), Box<dyn Error>> {
|
|
// Connect to a peer
|
|
let mut stream = TcpStream::connect("127.0.0.1:8080").await?;
|
|
let mut _buffer = [0, 16];
|
|
// Write some data.
|
|
stream.write_all(b"hello world!").await?;
|
|
|
|
Ok(())
|
|
}
|