Files
RedBear-OS/ipcd/examples/helloserver.rs
T
Red Bear OS bd595851e2 base: apply Red Bear patches on latest upstream/main
251 files: init, acpid, ipcd, netcfg, ihdgd, virtio-gpud, scheme-utils,
inputd, block driver, ptyd, ramfs, randd, initfs bootstrap, path deps,
version +rb0.3.1, author attribution
2026-07-11 11:39:24 +03:00

22 lines
554 B
Rust

use std::{
fs::File,
io::{self, prelude::*},
os::unix::io::{AsRawFd, FromRawFd, RawFd},
};
fn from_syscall_error(error: syscall::Error) -> io::Error {
io::Error::from_raw_os_error(error.errno as i32)
}
fn main() -> io::Result<()> {
let server = File::create("chan:hello")?;
loop {
let stream =
libredox::call::dup(server.as_raw_fd() as usize, b"listen").map_err(from_syscall_error)?;
let mut stream = unsafe { File::from_raw_fd(stream as RawFd) };
stream.write(b"Hello World!\n")?;
}
}