I am trying to connect to a server which is unreachable using the following code:
println!("Connecting");
TcpStream::connect(s).unwrap();
println!("Connected");
When I run the code, it gets stuck on second line.
Output:
Connecting
greetings from 2020.
In the meantime the answer changed, it's no longer "can't be done easily" but is:
TcpStream::connect_timeout()
https://doc.rust-lang.org/std/net/struct.TcpStream.html#method.connect_timeout
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With