fn recv(&mut self, expected_data: usize) -> Result<Vec<u8>, RPCError> {
        let mut data = vec![0; expected_data];
        let mut total_data_received = 0;

        loop {
            match self.iface.poll(&mut self.sockets, Instant::from_millis(0)) {
                Ok(_) => {}
                Err(e) => {
                    warn!("poll error: {}", e);
                }
            }

            if total_data_received == expected_data {
                return Ok(data);
            } else {
                let mut socket = self.sockets.get::<TcpSocket>(self.server_handle.unwrap());
                if socket.can_recv() {
                    if let Ok(bytes_received) =
                        socket.recv_slice(&mut data[total_data_received..expected_data])
                    {
                        total_data_received += bytes_received;
                        trace!(
                            "rcv got {:?}/{:?} bytes",
                            total_data_received,
                            expected_data
                        );
                    } else {
                        warn!("recv_slice failed... trying again?");
                    }
                }
            }
        }
    }
/// receive data from a remote node
receive data from a remote node
receive data from a remote node
fn recv(&mut self, expected_data: usize) -> Result<Vec<u8>, RPCError> {
        let mut data = vec![0; expected_data];
        let mut total_data_received = 0;
        loop {
            match self.iface.poll(&mut self.sockets, Instant::from_millis(0)) {
                Ok(_) => {}
                Err(e) => {
                    warn!("poll error: {}", e);
                }
            }
            if total_data_received == expected_data {
                return Ok(data);
            } else {
                let mut socket = self.sockets.get::<TcpSocket>(self.server_handle.unwrap());
                if socket.can_recv() {
                    if let Ok(bytes_received) =
                        socket.recv_slice(&mut data[total_data_received..expected_data])
                    {
                        total_data_received += bytes_received;
                        trace!(
                            "rcv got {:?}/{:?} bytes",
                            total_data_received,
                            expected_data
                        );
                    } else {
                        warn!("recv_slice failed... trying again?");
                    }
                }
            }
        }
    }
fn recv ( & mut self , expected_data : usize ) -> Result < Vec < u8 > , RPCError > { let mut data = vec ! [ 0 expected_data ] ; let mut total_data_received = 0 ; loop { match self . iface . poll ( & mut self . sockets , Instant :: from_millis ( 0 ) ) { Ok ( _ ) => { } Err ( e ) => { warn ! ( " " e ) ; } } if total_data_received == expected_data { return Ok ( data ) ; } else { let mut socket = self . sockets . get :: < TcpSocket > ( self . server_handle . unwrap ( ) ) ; if socket . can_recv ( ) { if let Ok ( bytes_received ) = socket . recv_slice ( & mut data [ total_data_received .. expected_data ] ) { total_data_received += bytes_received ; trace ! ( " " total_data_received expected_data ) ; } else { warn ! ( " " ) ; } } } } }
receive data from a remote node
receive data from a remote node
&mut self
expected_data
usize
&mut self
expected_data
usize