mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-27 00:00:12 +02:00
net: rewrite TcpStream::connect with async fn (#1497)
This also removes `TcpStream::connect_std` as the conversion functions from `std` need to be rethought. A note tracking this has been added to #1209.
This commit is contained in:
@@ -3,7 +3,8 @@ use tokio_net::tcp::{TcpListener, TcpStream};
|
||||
#[tokio::test]
|
||||
async fn split_reunite() -> std::io::Result<()> {
|
||||
let listener = TcpListener::bind(&"127.0.0.1:0".parse().unwrap())?;
|
||||
let stream = TcpStream::connect(&listener.local_addr()?).await?;
|
||||
let addr = listener.local_addr()?;
|
||||
let stream = TcpStream::connect(&addr).await?;
|
||||
|
||||
let (r, w) = stream.split();
|
||||
assert!(r.reunite(w).is_ok());
|
||||
@@ -13,8 +14,9 @@ async fn split_reunite() -> std::io::Result<()> {
|
||||
#[tokio::test]
|
||||
async fn split_reunite_error() -> std::io::Result<()> {
|
||||
let listener = TcpListener::bind(&"127.0.0.1:0".parse().unwrap())?;
|
||||
let stream = TcpStream::connect(&listener.local_addr()?).await?;
|
||||
let stream1 = TcpStream::connect(&listener.local_addr()?).await?;
|
||||
let addr = listener.local_addr()?;
|
||||
let stream = TcpStream::connect(&addr).await?;
|
||||
let stream1 = TcpStream::connect(&addr).await?;
|
||||
|
||||
let (r, _) = stream.split();
|
||||
let (_, w) = stream1.split();
|
||||
|
||||
Reference in New Issue
Block a user