Skip to content

TcpStream::connect_timeout with Duration::MAX never succeeds on Windows #112405

Closed
@hartwork

Description

@hartwork

Hello! 👋

I tried this code on Windows:

use std::net::{TcpStream, ToSocketAddrs};
use std::time::Duration;

fn main() {
    let address_result = "google.com:80".to_socket_addrs();
    let address = address_result.unwrap().next().unwrap();
    TcpStream::connect_timeout(&address, Duration::MAX).expect("Google is offline?!");
    println!("Never gets here on Windows (https://github.com/rust-lang/rust/issues/112405).");
}

I expected to see this happen: Success for an available address like google.com:80 and blocking forever (or until TCP timeout) for hostname.invalid:80 just like on Linux.

Instead, this happened: the call never succeeds, not even for google.com:80 on Windows.

Related: hartwork/rust-for-it@5056e69

Meta

rustc --version --verbose:

# rustc --version --verbose
rustc 1.69.0 (84c898d65 2023-04-16)
binary: rustc
commit-hash: 84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc
commit-date: 2023-04-16
host: x86_64-pc-windows-msvc
release: 1.69.0
LLVM version: 15.0.7

Metadata

Metadata

Assignees

Labels

A-ioArea: `std::io`, `std::fs`, `std::net` and `std::path`C-bugCategory: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-help-wantedCall for participation: Help is requested to fix this issue.O-windowsOperating system: WindowsT-libsRelevant to the library team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions