Open
Description
Hello so I am trying to work with x11rb inside wsl and have a working setup for an xserver (I have confirmed this through the weston program and was able to successful make a window using the xcb crate) however trying to use the following code results in an "thread 'main' panicked at 'unexpected address family 80', /home/digital/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.23.0/src/sys/socket/mod.rs:1878:15"
use std::net::TcpStream;
use std::os::unix::net::UnixStream;
use std::os::unix::io::{AsRawFd, RawFd};
use std::str::FromStr;
use nix::sys::socket::{recvmsg, sendmsg, MsgFlags};
use nix::sys::uio::IoVec;
// A X11 setup request
const TO_SEND: [u8; 12] = [
0x6c, // Byte order: little endian
0, 11, 0, 0, 0, // padding and protocol version
0, 0, 0, 0, 0, 0, // We don't send any authorisation + padding
];
fn test_stream(fd: RawFd) -> Result<(), Box<dyn std::error::Error>> {
let iov = [IoVec::from_slice(&TO_SEND[..])];
sendmsg(fd, &iov, &[], MsgFlags::empty(), None)?;
let mut buf = [0; 10];
let mut cmsg = nix::cmsg_space!([RawFd; 16]);
let result = recvmsg(fd, &[IoVec::from_mut_slice(&mut buf[..])], Some(&mut cmsg), MsgFlags::empty())?;
println!("recvmsg() returned {:?}", result);
Ok(())
}
fn try_tcp(display: u16) -> Result<(), Box<dyn std::error::Error>> {
test_stream(TcpStream::connect(("localhost", 6000 + display))?.as_raw_fd())
}
fn try_unix(display: u16) -> Result<(), Box<dyn std::error::Error>> {
let file = format!("/tmp/.X11-unix/X{}", display);
test_stream(UnixStream::connect(file)?.as_raw_fd())
}
fn main() {
// This should contain the value from the env:
// $ echo $DISPLAY
// :0
let display = std::env::args().skip(1).next().as_ref().and_then(|s| u16::from_str(s).ok()).unwrap_or(0);
println!("Connecting to DISPLAY=:{}", display);
println!("unix: {:?}", try_unix(display));
println!("tcp: {:?}", try_tcp(display));
}
not quite sure what is going on