You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 7, 2019. It is now read-only.
Running the following test program hangs and doesn't notice that the client has closed the write side of the TcpStream:
#![feature(futures_api, async_await, await_macro)]use std::{io, net::IpAddr};use futures::{StreamExt, io::{AsyncReadExt,AsyncWriteExt}};use romio::TcpListener;use romio::TcpStream;fnmain(){
futures::executor::block_on(async{let ip:IpAddr = "127.0.0.1".parse().unwrap();letmut listener = TcpListener::bind(&(ip,0).into()).unwrap();let port = listener.local_addr().unwrap().port();letmut incoming = listener.incoming();let(_rx,mut tx) = await!(TcpStream::connect(&(ip, port).into())).unwrap().split();let(mut rx, _tx) = await!(incoming.next()).unwrap().unwrap().split();println!("Connection established");println!("Closing tx");await!(tx.close()).unwrap();println!("Wait for server to notice connection was closed...");letmut byte = [0];let res = await!(rx.read_exact(&mut byte));assert!(res.is_err());assert_eq!(res.unwrap_err().kind(), io::ErrorKind::UnexpectedEof);})}
By adding in a wrapper around the clients TcpStream that implements poll_close to call shutdown(Shutdown::Write) the server notices that the client has closed the TCP connection
For some reason in the linked Tokio issue they don't want to apply this change to TcpStream itself, I can't see any reason not to just change it though.
This is very similar to tokio-rs/tokio#852.
Running the following test program hangs and doesn't notice that the client has closed the write side of the
TcpStream:By adding in a wrapper around the clients
TcpStreamthat implementspoll_closeto callshutdown(Shutdown::Write)the server notices that the client has closed the TCP connectionFor some reason in the linked Tokio issue they don't want to apply this change to
TcpStreamitself, I can't see any reason not to just change it though.