In nodejs I can detect close event for a socket but not in Rust
โ Rust ๐ 2025-08-01 ๐ค surdeus ๐๏ธ 10Hi folks. Iโm struggling a strange problem. I can detect the close event in nodejs for a TCP socket connection but I canโt do same thing in Rust (Tokio). For example:
// Javascript
let connection = new net.Socket();
connection.on("end", (data) => {
console.log("Connection finished.")
})
For example I can connect to this connection with CURL and when connection finishes the end function invokes. But I canโt do same thing in tokio::net::TcpStream
Yes I know that we canโt really understand that is the connection live. All network connections actaully isnโt exist but at least I want to detect the FIN flag sent from the peer. How can I do this?
7 posts - 4 participants
๐ท๏ธ Rust_feed