My TCPStream code is like this:
use std::error::Error;
use tokio::io::AsyncWriteExt;
use tokio::net::TcpStream;
#[tokio::main]
pub async fn match_tcp_client(address: String, self_ip: String) -> Result<(), Box<dyn Error>> {
// Connect to a peer
println!("client to connect at {}", address);
let mut stream = TcpStream::connect(address.clone()).await?;
println!("client done");
// Write some data.
stream.write_all(self_ip.as_bytes()).await?;
stream.write_all(b"hello world!EOF").await?;
// stream.shutdown().await?;
Ok(())
}
My question is, is there a way for client to know if server has correctly received the data, and if not resend the data?