We have a server at least #3

Merged
PlexSheep merged 14 commits from devel into master 2024-01-19 16:40:16 +01:00
4 changed files with 6 additions and 10 deletions
Showing only changes of commit 12a60eb189 - Show all commits

View File

@ -0,0 +1 @@

View File

@ -46,7 +46,6 @@ pub(crate) struct Cli {
#[arg(short, long, default_value_t = false)]
pub(crate) server: bool,
// how much threads the server should use
#[cfg(feature = "server")]
#[arg(short, long, default_value_t = 4)]

View File

@ -40,7 +40,7 @@ impl Display for Mode {
pub struct Config {
pub addr: std::net::SocketAddr,
pub mode: Mode,
pub threads: usize
pub threads: usize,
}
impl Config {
@ -48,7 +48,7 @@ impl Config {
Config {
addr: cli.addr.clone(),
mode: cli.mode.clone(),
threads: cli.threads
threads: cli.threads,
}
}
}

View File

@ -2,16 +2,12 @@
use anyhow::Result;
use libpt::log::{error, info};
use mio::{self, event::Event, net::TcpListener, Events, Interest, Poll, Token};
use std::{
io::{prelude::*, BufReader},
time::Duration,
};
use std::time::Duration;
use threadpool::ThreadPool;
use crate::common::conf::{Config, Mode};
use crate::common::conf::Config;
pub mod listener;
use listener::*;
const EVENT_CAPACITY: usize = 128;
const SERVER: Token = Token(0);
@ -59,7 +55,7 @@ impl Server {
fn handle_event(&self, event: &Event) -> Result<()> {
dbg!(event);
let connection = self.server.accept()?;
let _connection = self.server.accept()?;
info!("received a connection!");
Ok(())
}