Available on
target_family="unix" only.Expand description
Unix (domain) socket server module for Rama.
The Unix server is used to create a UnixListener and accept incoming connections.
§Example
use rama_unix::{UnixStream, server::UnixListener};
use rama_core::service::service_fn;
use tokio::io::AsyncWriteExt;
#[tokio::main]
async fn main() {
UnixListener::bind_path("/tmp/example.socket")
.await
.expect("bind Unix Listener")
.serve(service_fn(async |mut stream: UnixStream| {
stream
.write_all(b"Hello, Unix!")
.await
.expect("write to stream");
Ok::<_, std::convert::Infallible>(())
}))
.await;
}Structs§
- Unix
Listener - A Unix (domain) socket server, listening for incoming connections once served
using one of the
servemethods such asUnixListener::serve. - Unix
Listener Builder - Builder for
UnixListener.