Expand description
Socket Server - Unix Domain Socket / Named Pipe Server Module
This module provides a cross-platform Socket Server, similar to Docker’s
/var/run/docker.sock design pattern, serving as a unified entry point
for all IPC communications.
§Features
- Cross-platform support (Unix Domain Sockets on Unix, Named Pipes on Windows)
- Multiple client connections
- Connection lifecycle management
- Integration with existing IPC modules
§Example
use ipckit::{SocketServer, SocketServerConfig, Connection, Message};
let config = SocketServerConfig::default();
let server = SocketServer::new(config).unwrap();
// Handle connections
for conn in server.incoming() {
match conn {
Ok(mut connection) => {
// Handle the connection
if let Ok(msg) = connection.recv() {
connection.send(&Message::text("Hello!")).ok();
}
}
Err(e) => eprintln!("Connection error: {}", e),
}
}Structs§
- Connection
- A single client connection.
- Connection
Metadata - Connection metadata.
- FnHandler
- A simple function-based handler.
- Message
- A message that can be sent over the socket.
- Socket
Client - Socket client for connecting to a socket server.
- Socket
Server - Socket server for handling multiple client connections.
- Socket
Server Config - Socket server configuration.
Enums§
- Message
Type - Message type enumeration.
Traits§
- Connection
Handler - Connection handler trait for processing connections.
Functions§
- default_
socket_ path - Get the default socket path for the current platform.
Type Aliases§
- Connection
Id - Unique connection identifier.