pub fn parse_socket_addr_with_default_port(
    addr: &str,
    default_port: u16
) -> Result<SocketAddr>
Expand description

Attempts to parse a socket_addr. If no port is defined, it just accepts the address and uses the given default port.

This function supports

  • IPv4
  • IPv4:port
  • IPv6
  • [IPv6]:port – IpV6 contains colon. It is customary to require bracket for this reason.
  • hostname
  • hostname:port with or without a port.

Note that this function returns a SocketAddr, so that if a hostname is given, DNS resolution will happen once and for all.