/// Set up the client socket, and connect to the specified server peer
Set up the client socket, and connect to the specified server peer
Set up the client socket and connect to the specified server peer
async fn connect_to_server(
        local_addr: &SocketAddr,
        peer_addr: &SocketAddr,
        log: &ReplicaLogger,
    ) -> Result<TcpStream, TransportErrorCode> {
        let client_socket = Self::init_client_socket(local_addr, log)?;
        match Self::connect_status(client_socket.connect(*peer_addr).await) {
            ConnectStatus::Success(stream) => Self::set_send_sockopts(stream, log),
            ConnectStatus::ServerDown => Err(TransportErrorCode::ServerDown),
            ConnectStatus::Error(err_code) => {
                warn!(
                    log,
                    "ControlPlane::connect_to_server(): local_addr = {:?} peer_addr = {:?}, error {:?}",
                    local_addr,
                    peer_addr,
                    err_code,
                );
                Err(TransportErrorCode::ConnectOsError)
            }
        }
    }
async fn connect_to_server ( local_addr : & SocketAddr , peer_addr : & SocketAddr , log : & ReplicaLogger , ) -> Result < TcpStream , TransportErrorCode > { let client_socket = Self :: init_client_socket ( local_addr , log ) ? ; match Self :: connect_status ( client_socket . connect ( * peer_addr ) . await ) { ConnectStatus :: Success ( stream ) => Self :: set_send_sockopts ( stream , log ) , ConnectStatus :: ServerDown => Err ( TransportErrorCode :: ServerDown ) , ConnectStatus :: Error ( err_code ) => { warn ! ( log " " local_addr peer_addr err_code ) ; Err ( TransportErrorCode :: ConnectOsError ) } } }
Set up the client socket, and connect to the specified server peer
Set up the client socket and connect to the specified server peer
local_addr
&SocketAddr
peer_addr
&SocketAddr
log
&ReplicaLogger