mirror of
https://github.com/redstrate/Kawari.git
synced 2025-04-27 00:47:45 +00:00
29 lines
700 B
Rust
29 lines
700 B
Rust
|
use tokio::io::AsyncReadExt;
|
||
|
use tokio::net::TcpListener;
|
||
|
|
||
|
#[tokio::main]
|
||
|
async fn main() {
|
||
|
tracing_subscriber::fmt::init();
|
||
|
|
||
|
let listener = TcpListener::bind("127.0.0.1:7000").await.unwrap();
|
||
|
|
||
|
tracing::info!("Lobby server started on 7000");
|
||
|
|
||
|
loop {
|
||
|
let (socket, _) = listener.accept().await.unwrap();
|
||
|
let (mut read, _) = tokio::io::split(socket);
|
||
|
|
||
|
tokio::spawn(async move {
|
||
|
let mut buf = [0; 2056];
|
||
|
loop {
|
||
|
let n = read
|
||
|
.read(&mut buf)
|
||
|
.await
|
||
|
.expect("Failed to read data!");
|
||
|
|
||
|
println!("Recieved data: {:#?}", &buf[..n]);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
}
|