pub async fn connect(&self, peer: impl Into<String>) -> Result<()> {
        let peer_str = peer.into();
        let peer_addr;
        let hostnames;

        // Try to parse as SocketAddr
        if let Ok(p) = parse_socket_addr(peer_str.clone()) {
            peer_addr = p;
            hostnames = vec![];
        }
        // Try to resolve hostname
        else if let Ok(iter) = peer_str.to_socket_addrs() {
            // FIXME: We only take ipv4 for now
            if let Some(p) = iter.filter(|x| x.is_ipv4()).next() {
                peer_addr = p;
            } else {
                return Err(TcpError::InvalidAddress.into());
            }

            hostnames = vec![peer_str];
        } else {
            return Err(TcpError::InvalidAddress.into());
        }

        let pair = WorkerPair::start(&self.ctx, peer_addr, hostnames).await?;
        self.register(&pair).await?;

        Ok(())
    }
/// Establish an outgoing TCP connection on an existing transport
Establish an outgoing TCP connection on an existing transport
Establish an outgoing TCP connection on an existing transport
pub async fn connect(&self, peer: impl Into<String>) -> Result<()> {
        let peer_str = peer.into();
        let peer_addr;
        let hostnames;
        // Try to parse as SocketAddr
        if let Ok(p) = parse_socket_addr(peer_str.clone()) {
            peer_addr = p;
            hostnames = vec![];
        }
        // Try to resolve hostname
        else if let Ok(iter) = peer_str.to_socket_addrs() {
            // FIXME: We only take ipv4 for now
            if let Some(p) = iter.filter(|x| x.is_ipv4()).next() {
                peer_addr = p;
            } else {
                return Err(TcpError::InvalidAddress.into());
            }
            hostnames = vec![peer_str];
        } else {
            return Err(TcpError::InvalidAddress.into());
        }
        let pair = WorkerPair::start(&self.ctx, peer_addr, hostnames).await?;
        self.register(&pair).await?;
        Ok(())
    }
pub async fn connect ( & self , peer : impl Into < String > ) -> Result < ( ) > { let peer_str = peer . into ( ) ; let peer_addr ; let hostnames ; // Try to parse as SocketAddr if let Ok ( p ) = parse_socket_addr ( peer_str . clone ( ) ) { peer_addr = p ; hostnames = vec ! [ ] ; } // Try to resolve hostname else if let Ok ( iter ) = peer_str . to_socket_addrs ( ) { // FIXME: We only take ipv4 for now if let Some ( p ) = iter . filter ( | x | x . is_ipv4 ( ) ) . next ( ) { peer_addr = p ; } else { return Err ( TcpError :: InvalidAddress . into ( ) ) ; } hostnames = vec ! [ peer_str ] ; } else { return Err ( TcpError :: InvalidAddress . into ( ) ) ; } let pair = WorkerPair :: start ( & self . ctx , peer_addr , hostnames ) . await ? ; self . register ( & pair ) . await ? ; Ok ( ( ) ) }
Establish an outgoing TCP connection on an existing transport
Establish an outgoing TCP connection on an existing transport
&self
peer
impl Into<String>