sciter-sdk / rust-sciter

Rust bindings for Sciter
https://sciter.com
MIT License
804 stars 75 forks source link

why call set_options blocked the application #138

Open mycoco2014 opened 1 year ago

mycoco2014 commented 1 year ago

i have a demo both tokio_native_tls and async_native_tls will be blocked after set_options.

pub async fn test_tls_client()  {
    let addr = "14.215.177.39:443";
    let host = "www.baidu.com";

    let socket = TcpStream::connect(addr.clone()).await?;
    let cx = TlsConnector::builder().build()?;
    let cx = tokio_native_tls::TlsConnector::from(cx);

    let mut socket = cx.connect(host.clone(), socket).await?; // *** blocked there 

    socket.write_all(format!("\
             GET / HTTP/1.0\r\n\
             Host: {}\r\n\
             \r\n\
             ",host.clone())
                .as_bytes(),
        ).await?;

    let mut data = Vec::new();
    socket.read_to_end(&mut data).await?;
    println!("recv tls {}", String::from_utf8_lossy(&data[..]));
}

fn main() {
   std::thread::spawn(move || test_tls_client());
    use sciter::SCRIPT_RUNTIME_FEATURES::*;
    sciter::set_options(sciter::RuntimeOptions::ScriptFeatures(
       ALLOW_FILE_IO as u8
    ));
    let mut frame = sciter::WindowBuilder::main_window().create();
    frame.load_file("./src/minimal.htm");
    frame.run_app();
}

if i inited options by set_options function, then request tls will be block this demo.

what's the default options? why is blocked demo in https client?