/// Binds a TCP socket on the given address after having set the `SO_REUSEADDR`
/// and `SO_REUSEPORT` flags.
///
/// Setting the flags after binding to the port has no effect.
Binds a TCP socket on the given address after having set the `SO_REUSEADDR`
and `SO_REUSEPORT` flags.

Setting the flags after binding to the port has no effect.
Binds a TCP socket on the given address after having set the ` SO_REUSEADDR ` and ` SO_REUSEPORT ` flags . Setting the flags after binding to the port has no effect .
fn bind_tcp_socket_with_reuse(addr: SocketAddr) -> Result<Socket, Box<dyn Error>> {
    use socket2::{Domain, Protocol, SockAddr, Type};
    let domain = match &addr {
        SocketAddr::V4(_) => Domain::ipv4(),
        SocketAddr::V6(_) => Domain::ipv6(),
    };
    let socket = socket2::Socket::new(domain, Type::stream(), Some(Protocol::tcp()))?;
    #[cfg(all(unix, not(any(target_os = "solaris", target_os = "illumos"))))]
    {
        socket.set_reuse_address(true)?;
        socket.set_reuse_port(true)?;
    }
    socket.bind(&SockAddr::from(addr))?;
    Ok(socket)
}
fn bind_tcp_socket_with_reuse ( addr : SocketAddr ) -> Result < Socket , Box < dyn Error > > { use socket2 :: { Domain , Protocol , SockAddr , Type } ; let domain = match & addr { SocketAddr :: V4 ( _ ) => Domain :: ipv4 ( ) , SocketAddr :: V6 ( _ ) => Domain :: ipv6 ( ) , } ; let socket = socket2 :: Socket :: new ( domain , Type :: stream ( ) , Some ( Protocol :: tcp ( ) ) ) ? ; # [ cfg ( all ( unix not ( any ( target_os " " target_os " " ) ) ) ) ] { socket . set_reuse_address ( true ) ? ; socket . set_reuse_port ( true ) ? ; } socket . bind ( & SockAddr :: from ( addr ) ) ? ; Ok ( socket ) }
Binds a TCP socket on the given address after having set the `SO_REUSEADDR`
and `SO_REUSEPORT` flags.
Binds a TCP socket on the given address after having set the ` SO_REUSEADDR ` and ` SO_REUSEPORT ` flags .
addr
SocketAddr