pub(crate) fn bind_ephemeral() -> (Socket, SocketAddr) {
    use socket2::{Domain, Protocol, Type};

    let addr = SocketAddr::from(([127, 0, 0, 1], 0));
    let sock = Socket::new(Domain::IPV4, Type::STREAM, Some(Protocol::TCP)).expect("Socket::new");
    sock.bind(&addr.into()).expect("Socket::bind");
    let addr = sock
        .local_addr()
        .expect("Socket::local_addr")
        .as_socket()
        .expect("must be AF_INET");
    (sock, addr)
}
/// Binds a socket to an ephemeral port without starting listening on it.
///
/// Some tests require us to introduce a delay between binding the server
/// socket and listening on it. However, `tokio::net`'s
/// `TcpListener::bind` function both binds the socket _and_ starts
/// listening on it, so we can't just use that. Instead, we must manually
/// construct the socket using `socket2`'s lower-level interface to libc
///  socket APIs, and _then_ convert it into a Tokio `TcpListener`.
Binds a socket to an ephemeral port without starting listening on it.
Some tests require us to introduce a delay between binding the server
socket and listening on it. However, `tokio::net`'s
`TcpListener::bind` function both binds the socket _and_ starts
listening on it, so we can't just use that. Instead, we must manually
construct the socket using `socket2`'s lower-level interface to libc
socket APIs, and _then_ convert it into a Tokio `TcpListener`.
Binds a socket to an ephemeral port without starting listening on it . Some tests require us to introduce a delay between binding the server socket and listening on it . However ` tokio :: net ` ' s ` TcpListener :: bind ` function both binds the socket _and_ starts listening on it so we can ' t just use that . Instead we must manually construct the socket using ` socket2 ` ' s lower - level interface to libc socket APIs and _then_ convert it into a Tokio ` TcpListener ` .
pub(crate) fn bind_ephemeral() -> (Socket, SocketAddr) {
    use socket2::{Domain, Protocol, Type};
    let addr = SocketAddr::from(([127, 0, 0, 1], 0));
    let sock = Socket::new(Domain::IPV4, Type::STREAM, Some(Protocol::TCP)).expect("Socket::new");
    sock.bind(&addr.into()).expect("Socket::bind");
    let addr = sock
        .local_addr()
        .expect("Socket::local_addr")
        .as_socket()
        .expect("must be AF_INET");
    (sock, addr)
}
pub ( crate ) fn bind_ephemeral ( ) -> ( Socket , SocketAddr ) { use socket2 :: { Domain , Protocol , Type } ; let addr = SocketAddr :: from ( ( [ 127 , 0 , 0 , 1 ] , 0 ) ) ; let sock = Socket :: new ( Domain :: IPV4 , Type :: STREAM , Some ( Protocol :: TCP ) ) . expect ( " " ) ; sock . bind ( & addr . into ( ) ) . expect ( " " ) ; let addr = sock . local_addr ( ) . expect ( " " ) . as_socket ( ) . expect ( " " ) ; ( sock , addr ) }
Binds a socket to an ephemeral port without starting listening on it.
Binds a socket to an ephemeral port without starting listening on it .