Skip to content

TcpStream::connect_timeout doesn't fail to connect to a nonexistent server on Linux #45265

Closed
@sfackler

Description

@sfackler
use std::net::TcpStream;
use std::time::Duration;

fn main() {
    let sock = "127.0.0.1:1234".parse().unwrap();
    let timeout = Duration::from_secs(3);
    TcpStream::connect_timeout(&sock, timeout).unwrap();
}

This program succeeds on Linux, even though it shouldn't (assuming you don't have a listener on 1234). Trying to do anything with the socket produces Error { repr: Os { code: 107, message: "Transport endpoint is not connected" } }.

Metadata

Metadata

Assignees

No one assigned

    Labels

    O-linuxOperating system: LinuxT-libs-apiRelevant to the library API 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