/// Allocates the requested number of ports on a given IP address.
Allocates the requested number of ports on a given IP address.
Allocates the requested number of ports on a given IP address .
pub fn allocate_ports(ip_address: &str, num_ports: u16) -> Result<Vec<NodePort>, Box<dyn Error>> {
    let ip_address: IpAddr = ip_address.parse()?;
    let mut node_port_allocation = Vec::new();
    for _ in 0..num_ports {
        let socket = bind_tcp_socket_with_reuse(SocketAddr::from((ip_address, 0)))?;
        let local_addr = socket.local_addr()?.as_std().unwrap();
        node_port_allocation.push(NodePort {
            socket,
            port: local_addr.port(),
        });
        println!("Allocated Port {}", local_addr.port());
    }
    Ok(node_port_allocation)
}
pub fn allocate_ports ( ip_address : & str , num_ports : u16 ) -> Result < Vec < NodePort > , Box < dyn Error > > { let ip_address : IpAddr = ip_address . parse ( ) ? ; let mut node_port_allocation = Vec :: new ( ) ; for _ in 0 .. num_ports { let socket = bind_tcp_socket_with_reuse ( SocketAddr :: from ( ( ip_address , 0 ) ) ) ? ; let local_addr = socket . local_addr ( ) ? . as_std ( ) . unwrap ( ) ; node_port_allocation . push ( NodePort { socket , port : local_addr . port ( ) , } ) ; println ! ( " " local_addr port ( ) ) ; } Ok ( node_port_allocation ) }
Allocates the requested number of ports on a given IP address.
Allocates the requested number of ports on a given IP address .
ip_address
&str
num_ports
u16