🐛 bug: P2 no longer exits when P1 closes the connection

main
_ 2021-07-17 20:07:26 +00:00
parent fe25ff3d34
commit c8e44bb740
1 changed files with 33 additions and 26 deletions

View File

@ -27,10 +27,15 @@ async fn main () -> anyhow::Result <()> {
let mut resp_buf = [0u8, 0, 0, 0];
recv.read_exact (&mut resp_buf).await?;
debug! ("Waiting for local TCP client to connect to us");
let listener = TcpListener::bind ("127.0.0.1:30381").await?;
debug! ("Accepting local TCP connections");
loop {
let (tcp_socket, _) = listener.accept ().await?;
let connection = connection.clone ();
tokio::spawn (async move {
let (local_recv, local_send) = tcp_socket.into_split ();
debug! ("Connecting to end server");
@ -55,7 +60,9 @@ async fn main () -> anyhow::Result <()> {
ptth_conn.uplink_task.await??;
ptth_conn.downlink_task.await??;
Ok (())
Ok::<_, anyhow::Error> (())
});
}
}
struct PtthNewConnection {