pub async fn accept_incoming(
    settings: Settings,
    sender: Sender<Message>,
    state: SharedState,
    opt: Opt,
) -> Result<()> {
    //    // Commandline argument overwrites the configuration files values for address
    //    let address = if let Some(address) = opt.address.clone() {
    //        address
    //    } else {
    //        settings.daemon.address.clone()
    //    };

    // Commandline argument overwrites the configuration files values for port
    let port = if let Some(port) = opt.port.clone() {
        port
    } else {
        settings.daemon.port.clone()
    };
    //    let address = format!("{}:{}", address, port);
    let address = format!("127.0.0.1:{}", port);
    let listener = TcpListener::bind(address).await?;

    loop {
        // Poll if we have a new incoming connection.
        let (socket, _) = listener.accept().await?;
        let sender_clone = sender.clone();
        let state_clone = state.clone();
        let settings_clone = settings.clone();
        task::spawn(async move {
            let _result = handle_incoming(socket, sender_clone, state_clone, settings_clone).await;
        });
    }
}
/// Poll the unix listener and accept new incoming connections
/// Create a new future to handle the message and spawn it
Poll the unix listener and accept new incoming connections
Create a new future to handle the message and spawn it
Poll the unix listener and accept new incoming connections Create a new future to handle the message and spawn it
pub async fn accept_incoming(
    settings: Settings,
    sender: Sender<Message>,
    state: SharedState,
    opt: Opt,
) -> Result<()> {
    //    // Commandline argument overwrites the configuration files values for address
    //    let address = if let Some(address) = opt.address.clone() {
    //        address
    //    } else {
    //        settings.daemon.address.clone()
    //    };
    // Commandline argument overwrites the configuration files values for port
    let port = if let Some(port) = opt.port.clone() {
        port
    } else {
        settings.daemon.port.clone()
    };
    //    let address = format!("{}:{}", address, port);
    let address = format!("127.0.0.1:{}", port);
    let listener = TcpListener::bind(address).await?;
    loop {
        // Poll if we have a new incoming connection.
        let (socket, _) = listener.accept().await?;
        let sender_clone = sender.clone();
        let state_clone = state.clone();
        let settings_clone = settings.clone();
        task::spawn(async move {
            let _result = handle_incoming(socket, sender_clone, state_clone, settings_clone).await;
        });
    }
}
pub async fn accept_incoming ( settings : Settings , sender : Sender < Message > , state : SharedState , opt : Opt , ) -> Result < ( ) > { //    // Commandline argument overwrites the configuration files values for address //    let address = if let Some(address) = opt.address.clone() { //        address //    } else { //        settings.daemon.address.clone() //    }; // Commandline argument overwrites the configuration files values for port let port = if let Some ( port ) = opt . port . clone ( ) { port } else { settings . daemon . port . clone ( ) } ; //    let address = format!("{}:{}", address, port); let address = format ! ( " " port ) ; let listener = TcpListener :: bind ( address ) . await ? ; loop { // Poll if we have a new incoming connection. let ( socket , _ ) = listener . accept ( ) . await ? ; let sender_clone = sender . clone ( ) ; let state_clone = state . clone ( ) ; let settings_clone = settings . clone ( ) ; task :: spawn ( async move { let _result = handle_incoming ( socket , sender_clone , state_clone , settings_clone ) . await ; } ) ; } }
Poll the unix listener and accept new incoming connections
Create a new future to handle the message and spawn it
Poll the unix listener and accept new incoming connections Create a new future to handle the message and spawn it
settings
Settings
sender
Sender<Message>
state
SharedState
opt
Opt
settings
Settings
sender
Sender<Message>
state
SharedState
opt
Opt