summaryrefslogtreecommitdiff
path: root/examples/udp_async.rs
diff options
context:
space:
mode:
authorzy <[email protected]>2023-08-23 05:04:36 +0000
committerzy <[email protected]>2023-08-23 05:04:36 +0000
commitad0311c0f7faf29dd52f36c91cfb59a8af49d001 (patch)
tree6b7dfe37d2b6422b16f82b8acbb1b34ebbbc4467 /examples/udp_async.rs
parente5038c5b0c1d5ee8026290d22734d79818533eef (diff)
udp 代码清理dev
Diffstat (limited to 'examples/udp_async.rs')
-rw-r--r--examples/udp_async.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/examples/udp_async.rs b/examples/udp_async.rs
index 606b6cd..5fdc1ef 100644
--- a/examples/udp_async.rs
+++ b/examples/udp_async.rs
@@ -2,8 +2,7 @@
//! Use `nc -u 127.0.0.1 30000` to connect.
use mini_rust_runtime::executor::Executor;
-use mini_rust_runtime::udp::UdpSocket;
-use tokio::io::{AsyncReadExt, AsyncWriteExt};
+use mini_rust_runtime::net::udp::UdpSocket;
fn main() {
let ex = Executor::new(); // 执行器实例
@@ -17,6 +16,7 @@ async fn server() {
match socket.recv_from_async(&mut buf).await {
Ok((n, addr)) => {
println!("recv_from {} {} bytes", addr, n);
+ println!("Received data {:?}", &buf[..n]);
if n == 0 || socket.send_to_async(&buf[..n], &addr).await.is_err() {
// 回写
return;