0.1.1: small tcp socket fixes

Signed-off-by: Ivan Bushchik <ivabus@ivabus.dev>
This commit is contained in:
Ivan Bushchik 2024-01-28 21:07:23 +03:00
parent c2d3ad0389
commit d32aceb82c
No known key found for this signature in database
GPG key ID: 2F16FBF3262E090C
3 changed files with 11 additions and 4 deletions

2
Cargo.lock generated
View file

@ -320,7 +320,7 @@ checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
[[package]] [[package]]
name = "lonelyradio" name = "lonelyradio"
version = "0.1.0" version = "0.1.1"
dependencies = [ dependencies = [
"chrono", "chrono",
"clap", "clap",

View file

@ -1,7 +1,7 @@
[package] [package]
name = "lonelyradio" name = "lonelyradio"
description = "TCP radio for singles" description = "TCP radio for singles"
version = "0.1.0" version = "0.1.1"
edition = "2021" edition = "2021"
license = "MIT" license = "MIT"
authors = [ "Ivan Bushchik <ivabus@ivabus.dev>" ] authors = [ "Ivan Bushchik <ivabus@ivabus.dev>" ]

View file

@ -106,8 +106,15 @@ async fn stream(mut s: TcpStream) {
) )
.unwrap(); .unwrap();
for sample in samples { for sample in samples {
if s.write(&((sample * 32768_f32) as i16).to_le_bytes()).await.is_err() { let result = s.write(&((sample * 32768_f32) as i16).to_le_bytes()).await;
break 'track; if result.is_err() {
// Socket error -> stop
return;
} else {
if result.unwrap() == 0 {
// If socket cannot accept data -> stop
return;
}
} }
} }
continue; continue;