ivila commented on code in PR #164: URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#discussion_r1922949853
########## examples/udp_socket-rs/ta/src/main.rs: ########## @@ -52,17 +53,64 @@ fn destroy() { fn invoke_command(cmd_id: u32, _params: &mut Parameters) -> Result<()> { trace_println!("[+] TA invoke command"); match Command::from(cmd_id) { - Command::Start => { - udp_socket(); - Ok(()) - } + Command::Start => udp_socket(), _ => Err(Error::new(ErrorKind::BadParameters)), } } -fn udp_socket() { - let mut stream = UdpSocket::connect("127.0.0.1", 34254).unwrap(); - stream.write_all(b"[TA]: Hello, Teaclave!").unwrap(); +#[cfg(not(target_os = "optee"))] +fn udp_socket() -> Result<()> { + use alloc::string::String; + use alloc::vec::Vec; + use optee_utee::net::Setup; + + let setup = Setup::new_v4("127.0.0.1", 34254)?; + let mut stream = UdpSocket::open(setup).map_err(|err| { Review Comment: Actually, we cannot. This is a pain point in Rust: `std::io::Error` doesn't live in core because it uses unwinding, meaning many things cannot be used in no_std, especially `std::io::{Read, Write}`. Therefore, we cannot make them the same, because in std, the return error type should be `std::io::Error`, but we cannot use it in no_std. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@teaclave.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@teaclave.apache.org For additional commands, e-mail: dev-h...@teaclave.apache.org