[−][src]Function postfix_policy::handle_connection
pub fn handle_connection<'socket, 'ctx, HandlerType, ContextType, ErrorType, SocketType>(
socket: &'socket SocketType,
ctx: &'ctx ContextType
) -> Result<(), PostfixPolicyError<ErrorType>> where
HandlerType: PolicyRequestHandler<'ctx, ContextType, ErrorType>,
&'socket SocketType: Read + Write,
Handles a connection to the mail server.
socket
is the connection to the mail server and ctx
is the Context, passed through each time PolicyRequestHandler::new
is called.
It will create a new instance of the given PolicyRequestHandler
for every request.
Might handle multiple policy requests before returning.
Example
let listener = UnixListener::bind(socket_path).expect("Could not bind UNIX socket");
for conn in listener.incoming() {
let mut conn = conn?;
let cfg_ref = &config;
thread::spawn(move || {
if let Err(e) = handle_connection::<MyHandlerType, _, _, _>(&mut conn, cfg_ref) {
println!("handle_connection failed: {:?}", e);
};
});
}