Module socket_server

Module socket_server 

Source
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.
ConnectionMetadata
Connection metadata.
FnHandler
A simple function-based handler.
Message
A message that can be sent over the socket.
SocketClient
Socket client for connecting to a socket server.
SocketServer
Socket server for handling multiple client connections.
SocketServerConfig
Socket server configuration.

Enums§

MessageType
Message type enumeration.

Traits§

ConnectionHandler
Connection handler trait for processing connections.

Functions§

default_socket_path
Get the default socket path for the current platform.

Type Aliases§

ConnectionId
Unique connection identifier.