
Description
Hello,
I'm using stable Rust 1.27.0
.
According to man 7 unix
, about abstract socket:
an abstract socket address is distinguished (from a pathname socket) by the fact that
sun_path[0]
is anull
byte ('\0'
). The socket's address in this namespace is given by the additional bytes insun_path
that are covered by the specified length of the address structure. (Null bytes in the name have no special significance.) The name has no connection with filesystem pathnames. When the address of an abstract socket is returned, the returnedaddrlen
is greater thansizeof(sa_family_t)
(i.e., greater than 2), and the name of the socket is contained in the first(addrlen - sizeof(sa_family_t))
bytes ofsun_path
.
I failed to run this:
use std::os::unix::net::UnixListener;
use std::path::PathBuf;
fn main() {
let sock_path = PathBuf::from("\0test");
match UnixListener::bind(&sock_path) {
Ok(_) => println!("Server running at {:?}", &sock_path),
Err(err) => eprintln!("Failed to start server: {}", &err),
};
}
The error message was paths may not contain interior null bytes
. I searched and found the code here:
https://doc.rust-lang.org/src/std/sys/unix/ext/net.rs.html#61
I consider this a bug, but I'm really not sure. May I ask if you could help?
Thank you,