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 {
|
||||
if let Ok((mut stream, _)) = listener.accept().await {
|
||||
let mut buffer = vec![0; 1024];
|
||||
if let Ok(size) = stream.read(&mut buffer).await {
|
||||
buffer.truncate(size);
|
||||
if let Ok((data, _)) = Data::from_bytes((&buffer, 0)) {
|
||||
println!("Received: {:?}", data);
|
||||
// Process the data or save it to the database
|
||||
loop {
|
||||
if let Ok(size) = stream.read(&mut buffer).await {
|
||||
buffer.truncate(size);
|
||||
if let Ok((data, _)) = Data::from_bytes((&buffer, 0)) {
|
||||
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