generated from PlexSheep/rs-base
We have a server at least #3
|
@ -0,0 +1 @@
|
|||
|
|
@ -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)]
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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(())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue