Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/libstd/net/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1675,9 +1675,13 @@ mod tests {

#[test]
fn connect_timeout_unroutable() {
// this IP is unroutable, so connections should always time out,
// provided the network is reachable to begin with.
let addr = "10.255.255.1:80".parse().unwrap();
// We want an IP address that is always unreachable and will trigger a
// timeout, regardless of whether a network connection is available or
// not. IPv4 doesn't have any address that is guaranteed to be
// unreachable, but 192.0.2.0 is part of the TEST-NET-1 address block,
// which is reserved for documentation and examples, and so is very
// likely to be unreachable.
let addr = "192.0.2.0:80".parse().unwrap();
let e = TcpStream::connect_timeout(&addr, Duration::from_millis(250)).unwrap_err();
assert!(e.kind() == io::ErrorKind::TimedOut ||
e.kind() == io::ErrorKind::Other,
Expand Down