From 21264f1d33474338815865c9d3fa8b5a7bb4c6f1 Mon Sep 17 00:00:00 2001 From: j-vanderstoep <37811630+j-vanderstoep@users.noreply.github.com> Date: Fri, 28 May 2021 09:03:27 +0200 Subject: [PATCH] tcp: assign an unused port (#3817) --- tokio/tests/tcp_into_std.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tokio/tests/tcp_into_std.rs b/tokio/tests/tcp_into_std.rs index a46aace7f..4bf24c14d 100644 --- a/tokio/tests/tcp_into_std.rs +++ b/tokio/tests/tcp_into_std.rs @@ -10,10 +10,11 @@ use tokio::net::TcpStream; #[tokio::test] async fn tcp_into_std() -> Result<()> { let mut data = [0u8; 12]; - let listener = TcpListener::bind("127.0.0.1:34254").await?; + let listener = TcpListener::bind("127.0.0.1:0").await?; + let addr = listener.local_addr().unwrap().to_string(); let handle = tokio::spawn(async { - let stream: TcpStream = TcpStream::connect("127.0.0.1:34254").await.unwrap(); + let stream: TcpStream = TcpStream::connect(addr).await.unwrap(); stream });