-
Notifications
You must be signed in to change notification settings - Fork 1k
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
The sockaddr_in is missing documentation of the sin_len
field.
#3414
Comments
Some oses do have it (e.g. BSD based systems) some don't like Linux/Android indeed. |
with your code snippet on my linux machine it builds ok cargo build
Compiling sockin v0.1.0 (/tmp/sockin)
warning: unused imports: accept, bind, connect, listen
--> src/main.rs:1:20
|
1 | use libc::{socket, bind, accept, listen, connect, close};
| ^^^^ ^^^^^^ ^^^^^^ ^^^^^^^
|
= note: #[warn(unused_imports)] on by default
warning: unused import: sockaddr
--> src/main.rs:2:25
|
2 | use libc::{sockaddr_in, sockaddr, in_addr};
| ^^^^^^^^
warning: unused variable: servaddr
--> src/main.rs:10:13
|
10 | let servaddr = sockaddr_in{sin_zero:[0;8],
| ^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_servaddr`
|
= note: `#[warn(unused_variables)]` on by default
warning: `sockin` (bin "sockin") generated 3 warnings (run `cargo fix --bin "sockin"` to apply 3 suggestions)
Finished dev [unoptimized + debuginfo] target(s) in 0.13s however cargo build --target x86_64-unknown-freebsd
Compiling sockin v0.1.0 (/tmp/sockin)
warning: unused imports: `accept`, `bind`, `connect`, `listen`
--> src/main.rs:1:20
|
1 | use libc::{socket, bind, accept, listen, connect, close};
| ^^^^ ^^^^^^ ^^^^^^ ^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
warning: unused import: `sockaddr`
--> src/main.rs:2:25
|
2 | use libc::{sockaddr_in, sockaddr, in_addr};
| ^^^^^^^^
error[E0063]: missing field `sin_len` in initializer of `sockaddr_in`
--> src/main.rs:10:24
|
10 | let servaddr = sockaddr_in{sin_zero:[0;8],
| ^^^^^^^^^^^ missing `sin_len`
For more information about this error, try `rustc --explain E0063`.
warning: `sockin` (bin "sockin") generated 2 warnings
error: could not compile `sockin` (bin "sockin") due to previous error; 2 warnings emitted |
@jweinst1 We would like to know your target to add the declaration. |
My target is as follows
|
The following code
Fails to compile with
In https://docs.rs/libc/latest/libc/struct.sockaddr_in.html , there is no documentation of the
sin_len
field of the struct.Also i have never heard of this field in C types themselves for
sockaddr_in
, https://man7.org/linux/man-pages/man3/sockaddr.3type.html so unclear what this field is or does.The text was updated successfully, but these errors were encountered: