DemesneGH commented on code in PR #164:
URL: 
https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/164#discussion_r1922436398


##########
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:
   Seems the API design aligns with the OP-TEE raw API. Is it possible to make 
it consistent with the `std` API similar to `std::net`?  then the TA code can 
remain mostly unchanged for both `std` and `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

Reply via email to