File: issue_182.rs

package info (click to toggle)
rust-async-io 2.3.3-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 388 kB
  • sloc: makefile: 2
file content (24 lines) | stat: -rw-r--r-- 664 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//! https://github.com/smol-rs/async-io/issues/182

use async_io::Async;
use std::net::{TcpStream, ToSocketAddrs};

#[test]
fn networking_initialized() {
    let address = match ToSocketAddrs::to_socket_addrs(&("google.com", 80)) {
        Ok(mut addrs) => addrs.next().unwrap(),
        Err(err) => {
            eprintln!("Got error {err} when looking up google.com, exiting test early.");
            return;
        }
    };

    // Make sure we can access the host normally.
    if TcpStream::connect(address).is_err() {
        return;
    }

    async_io::block_on(async move {
        let _ = Async::<TcpStream>::connect(address).await.unwrap();
    });
}