Sending different commands via the client
Our client is simple, and it is going to stay simple. First, we must ensure our read and write traits are imported as this time, we will be reading a response. Our imports in the src/main.rs
file should look like this:
use tokio::net::TcpStream; use tokio::io::{BufReader, AsyncBufReadExt, AsyncWriteExt}; use std::error::Error;
Then, we must write a series of messages to our connection and then read until we get a new line:
#[tokio::main] async fn main() -> Result<(), Box<dyn Error>> { let mut stream = TcpStream::connect("127.0.0.1:8080").await?; let (reader, mut writer) = stream.split(); println!("stream starting"); writer.write_all(b"BUY;8.0;BYND;\nBUY;9.0;PLTR\n ...