1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-06-28 12:10:37 +02:00

update mio to 0.8

This commit is contained in:
Rob Ede
2021-11-15 18:48:37 +00:00
parent 54d1d9e520
commit ae28ce5377
3 changed files with 22 additions and 21 deletions

View File

@ -1,5 +1,4 @@
use std::sync::mpsc;
use std::{io, net, thread};
use std::{io, net, sync::mpsc, thread};
use actix_rt::{net::TcpStream, System};
@ -105,12 +104,16 @@ impl TestServer {
/// Get first available unused local address.
pub fn unused_addr() -> net::SocketAddr {
use socket2::{Domain, Protocol, Socket, Type};
let addr: net::SocketAddr = "127.0.0.1:0".parse().unwrap();
let socket = mio::net::TcpSocket::new_v4().unwrap();
socket.bind(addr).unwrap();
socket.set_reuseaddr(true).unwrap();
let tcp = socket.listen(1024).unwrap();
tcp.local_addr().unwrap()
let socket =
Socket::new(Domain::for_address(addr), Type::STREAM, Some(Protocol::TCP)).unwrap();
socket.set_reuse_address(true).unwrap();
socket.set_nonblocking(true).unwrap();
socket.bind(&addr.into()).unwrap();
socket.listen(1024).unwrap();
net::TcpListener::from(socket).local_addr().unwrap()
}
}