#[cfg(not(windows))]
fn main() {
eprintln!("This example is not available on platforms other than Windows.");
}
#[cfg(windows)]
fn main() -> std::io::Result<()> {
use {interprocess::os::windows::named_pipe::*, recvmsg::prelude::*};
let name = r"\\.\pipe\Example";
let mut buffer = MsgBuf::from(Vec::with_capacity(128));
let mut conn = DuplexPipeStream::<pipe_mode::Messages>::connect_by_path(name)?;
const MESSAGE: &[u8] = b"Hello from client!";
let sent = conn.send(MESSAGE)?;
assert_eq!(sent, MESSAGE.len());
conn.recv_msg(&mut buffer, None)?;
drop(conn);
let received_string = String::from_utf8_lossy(buffer.filled_part());
println!("Server answered: {received_string}");
Ok(())
}