You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@teaclave.apache.org by rd...@apache.org on 2022/11/15 01:14:50 UTC

[incubator-teaclave-sgx-sdk] 03/03: Fix mio samplecode

This is an automated email from the ASF dual-hosted git repository.

rduan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-teaclave-sgx-sdk.git

commit c3d82372dff81e5bafb07f71bc8ad532d06b504e
Author: volcano0dr <vo...@163.com>
AuthorDate: Sat Nov 5 22:16:19 2022 +0800

    Fix mio samplecode
---
 samplecode/mio/client/enclave/src/lib.rs | 5 +++--
 samplecode/mio/server/enclave/src/lib.rs | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/samplecode/mio/client/enclave/src/lib.rs b/samplecode/mio/client/enclave/src/lib.rs
index 6e1381c6..a539db42 100644
--- a/samplecode/mio/client/enclave/src/lib.rs
+++ b/samplecode/mio/client/enclave/src/lib.rs
@@ -27,7 +27,7 @@ extern crate sgx_tstd as std;
 
 use std::collections;
 use std::untrusted::fs;
-use std::net::SocketAddr;
+use std::net::{self, SocketAddr};
 use std::str;
 use std::io;
 use std::string::String;
@@ -337,7 +337,8 @@ pub extern "C" fn run_client() {
     let flag_http = true;
 
     let config = make_config(cert);
-    let sock = TcpStream::connect(&addr).unwrap();
+    let stream = net::TcpStream::connect(&addr).expect("connect failed");
+    let sock = TcpStream::from_stream(stream).unwrap();
 
     let dns_name = webpki::DNSNameRef::try_from_ascii_str(hostname).unwrap();
     let mut tlsclient = TlsClient::new(sock, dns_name, config);
diff --git a/samplecode/mio/server/enclave/src/lib.rs b/samplecode/mio/server/enclave/src/lib.rs
index 4013e3ed..2560d59c 100644
--- a/samplecode/mio/server/enclave/src/lib.rs
+++ b/samplecode/mio/server/enclave/src/lib.rs
@@ -439,7 +439,8 @@ pub extern "C" fn run_server(max_conn: uint8_t) {
 
     let config = make_config(cert, key);
 
-    let listener = TcpListener::bind(&addr).expect("cannot listen on port");
+    let listener = net::TcpListener::bind(&addr).expect("cannot listen on port");
+    let listener = TcpListener::from_std(listener).unwrap();
     let mut poll = mio::Poll::new()
         .unwrap();
     poll.register(&listener,


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@teaclave.apache.org
For additional commands, e-mail: commits-help@teaclave.apache.org