Finished the abstraction of the configuration socket
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
use std::net::TcpListener;
|
||||
use std::os::unix::net::UnixListener;
|
||||
use crate::conf;
|
||||
use crate::server_conf::conexion::Conexion;
|
||||
use crate::server_conf::listener::GenericListener;
|
||||
@@ -8,14 +6,14 @@ use std::sync::{Arc, RwLock};
|
||||
|
||||
pub struct ConfSer{
|
||||
path: String,
|
||||
listener: UnixListener,
|
||||
listener: GenericListener,
|
||||
}
|
||||
|
||||
impl ConfSer {
|
||||
fn new(path: String) -> ConfSer{
|
||||
ConfSer{
|
||||
path: path.clone(),
|
||||
listener: UnixListener::bind(path).unwrap(),
|
||||
listener: GenericListener::bind(path, 1).unwrap(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,13 +29,13 @@ impl Drop for ConfSer {
|
||||
pub fn start(conf: Arc<RwLock<conf::Config>>){
|
||||
let ser = ConfSer::new(String::from("mineproxy"));
|
||||
|
||||
for stream in ser.listener.incoming() {
|
||||
match stream{
|
||||
Ok(s) => {
|
||||
loop{
|
||||
match ser.listener.accept() {
|
||||
Ok(stream) => {
|
||||
let c = conf.clone();
|
||||
thread::spawn(|| Conexion::new(c, s).process_reques());
|
||||
},
|
||||
Err(_e) => println!("{}",_e),
|
||||
thread::spawn(|| Conexion::new(c, stream).process_reques());
|
||||
}
|
||||
Err(e) => println!("{}", e)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user