1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-06-26 06:57:43 +02:00

Update to socket2 v0.4 (#2092)

This commit is contained in:
Thomas de Zeeuw
2021-03-19 12:17:06 +00:00
committed by GitHub
parent 351286486c
commit 9488757c29
5 changed files with 9 additions and 12 deletions

View File

@ -118,10 +118,10 @@ pub async fn test_server_with_addr<F: ServiceFactory<TcpStream>>(
/// Get first available unused address
pub fn unused_addr() -> net::SocketAddr {
let addr: net::SocketAddr = "127.0.0.1:0".parse().unwrap();
let socket = Socket::new(Domain::ipv4(), Type::stream(), Some(Protocol::tcp())).unwrap();
let socket = Socket::new(Domain::IPV4, Type::STREAM, Some(Protocol::TCP)).unwrap();
socket.bind(&addr.into()).unwrap();
socket.set_reuse_address(true).unwrap();
let tcp = socket.into_tcp_listener();
let tcp = net::TcpListener::from(socket);
tcp.local_addr().unwrap()
}