ivmarkov / rust-esp32-std-demo

Rust on ESP32 STD demo app. A demo STD binary crate for the ESP32[XX] and ESP-IDF, which connects to WiFi, Ethernet, drives a small HTTP server and draws on a LED screen.
Apache License 2.0
784 stars 105 forks source link

Async TcpStream #75

Closed relufi closed 2 years ago

relufi commented 2 years ago

I encountered an exception while running the following code

let stream = smol::Async::<std::net::TcpStream>::connect("one.one.one.one:80".to_socket_addrs().unwrap().next().unwrap()).await;

Err(Os { code: 88, kind: Unsupported, message: "Function not implemented" })

The error is here https://github.com/esp-rs-compat/socket2/blob/9cdd55ac7abc59aa6613a1302eb3d8bcdbe56ab7/src/socket.rs#L707

ivmarkov commented 2 years ago

Coincidentally, we discussed precisely this issue with another user on the forum.

What we need to do is patch the socket2 crate (note that it is forked and partially patched already), and remove (for ESP-IDF only, i.e. #[cfg(not(target_os = "esp-idf"))]) ALL settings of the *CLOEXEC flags on the socket file descriptors, because this flag is not supported by ESP-IDF / LwIP and causes your failure.

Are you up for that?

ivmarkov commented 2 years ago

This should be fixed now. You might need to remove your socket2 checkout from ~/.cargo as the fix was force-pushed.

Please reopen if it still does not work for you.