-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting TCP_NODELAY does not work using std::net::TcpStream #218
Comments
I think I found the bug. LWIP defines TCP_NODELAY as 1 in esp-idf/components/lwip/lwip/src/include/lwip/sockets.h: #define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */ While Rust uses the libc::TCP_NODELAY with a value of 8193 defined by the libc crate in src/unix/newlib/mod.rs: cfg_if! {
if #[cfg(target_os = "vita")] {
pub const TCP_NODELAY: ::c_int = 1;
pub const TCP_MAXSEG: ::c_int = 2;
} else {
pub const TCP_NODELAY: ::c_int = 8193;
pub const TCP_MAXSEG: ::c_int = 8194;
}
} |
I found this pull request that would fix this issue on the libc crate repository: rust-lang/libc#3345 |
I've hit the same, for now I've done this as a workaround extern "C" {
fn lwip_setsockopt(fd: i32, level: i32, optname: i32);
}
unsafe {
lwip_setsockopt(
conn.as_raw_fd(),
6, // tcp https://github.com/stm32duino/LwIP/blob/main/src/lwip/sockets.h#L250
1, // nodelay https://github.com/stm32duino/LwIP/blob/main/src/lwip/sockets.h#L279
)
}; |
Closed via rust-lang/libc#3920 |
I tried this code:
I expected to see this happen: the socket should have been put in nodelay mode without issue.
Instead, this happened:
The TCP_NODELAY option should be supported: https://docs.espressif.com/projects/esp-idf/en/v5.2.1/esp32/api-guides/lwip.html#tcp-options
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: