mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-10-01 12:20:39 +00:00
tcp: assign an unused port (#3817)
This commit is contained in:
parent
81ee3d202a
commit
21264f1d33
@ -10,10 +10,11 @@ use tokio::net::TcpStream;
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn tcp_into_std() -> Result<()> {
|
async fn tcp_into_std() -> Result<()> {
|
||||||
let mut data = [0u8; 12];
|
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 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
|
stream
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user