]> git.lizzy.rs Git - connect-rs.git/blobdiff - examples/tcp-client/src/main.rs
make async-oriented, remove block_on
[connect-rs.git] / examples / tcp-client / src / main.rs
index f1b1d5fc084cab92cef447afe87fa98c2a5f75b3..c65a45548cb32894155e443b1409105b67237902 100644 (file)
@@ -21,16 +21,16 @@ async fn main() -> anyhow::Result<()> {
     };
 
     // create a client connection to the server
-    let mut conn = Connection::tcp_client(ip_address)?;
+    let mut conn = Connection::tcp_client(ip_address).await?;
 
     // send a message to the server
     let raw_msg = String::from("Hello world");
-    info!("Sending message: {}", raw_msg);
 
     let mut msg = HelloWorld::new();
-    msg.set_message(raw_msg);
+    msg.set_message(raw_msg.clone());
 
     conn.writer().send(msg).await?;
+    info!("Sent message: {}", raw_msg);
 
     // wait for the server to reply with an ack
     while let Some(reply) = conn.reader().next().await {