@@ -5,9 +5,6 @@ cfg_if::cfg_if! {
5
5
} else if #[ cfg( all( target_os = "linux" , target_env = "gnu" ) ) ] {
6
6
#[ path = "glibc.rs" ]
7
7
mod sys;
8
- } else if #[ cfg( unix) ] {
9
- #[ path = "unix.rs" ]
10
- mod sys;
11
8
}
12
9
}
13
10
@@ -20,6 +17,7 @@ use std::{
20
17
use compio_buf:: { buf_try, BufResult } ;
21
18
use either:: Either ;
22
19
20
+ #[ cfg( any( windows, all( target_os = "linux" , target_env = "gnu" ) ) ) ]
23
21
pub async fn resolve_sock_addrs (
24
22
host : & str ,
25
23
port : u16 ,
@@ -48,7 +46,7 @@ pub async fn resolve_sock_addrs(
48
46
unsafe { resolver. addrs ( ) }
49
47
}
50
48
51
- #[ allow ( dead_code ) ]
49
+ #[ cfg ( any ( windows , all ( target_os = "linux" , target_env = "gnu" ) ) ) ]
52
50
fn to_addrs ( mut result : * mut sys:: addrinfo , port : u16 ) -> std:: vec:: IntoIter < SocketAddr > {
53
51
use socket2:: SockAddr ;
54
52
@@ -77,6 +75,21 @@ fn to_addrs(mut result: *mut sys::addrinfo, port: u16) -> std::vec::IntoIter<Soc
77
75
addrs. into_iter ( )
78
76
}
79
77
78
+ #[ cfg( all( unix, not( all( target_os = "linux" , target_env = "gnu" ) ) ) ) ]
79
+ pub async fn resolve_sock_addrs (
80
+ host : & str ,
81
+ port : u16 ,
82
+ ) -> io:: Result < std:: vec:: IntoIter < SocketAddr > > {
83
+ use std:: net:: ToSocketAddrs ;
84
+
85
+ use compio_runtime:: Runtime ;
86
+
87
+ let host = host. to_string ( ) ;
88
+ Runtime :: current ( )
89
+ . spawn_blocking ( move || ( host, port) . to_socket_addrs ( ) )
90
+ . await
91
+ }
92
+
80
93
/// A trait for objects which can be converted or resolved to one or more
81
94
/// [`SocketAddr`] values.
82
95
///
0 commit comments