added loop to listener
This commit is contained in:
parent
38a0f4d189
commit
87416e5af9
1 changed files with 11 additions and 5 deletions
|
@ -53,11 +53,17 @@ async fn main() -> std::io::Result<()> {
|
||||||
loop {
|
loop {
|
||||||
if let Ok((mut stream, _)) = listener.accept().await {
|
if let Ok((mut stream, _)) = listener.accept().await {
|
||||||
let mut buffer = vec![0; 1024];
|
let mut buffer = vec![0; 1024];
|
||||||
if let Ok(size) = stream.read(&mut buffer).await {
|
loop {
|
||||||
buffer.truncate(size);
|
if let Ok(size) = stream.read(&mut buffer).await {
|
||||||
if let Ok((data, _)) = Data::from_bytes((&buffer, 0)) {
|
buffer.truncate(size);
|
||||||
println!("Received: {:?}", data);
|
if let Ok((data, _)) = Data::from_bytes((&buffer, 0)) {
|
||||||
// Process the data or save it to the database
|
println!("Received: {:?}", data);
|
||||||
|
// Process the data or save it to the database
|
||||||
|
} else {
|
||||||
|
println!("Failed to parse data");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue