pub fn listen(&self) -> Result<(), Error> {
		// start TCP listener and handle incoming connections
		let addr = SocketAddr::new(self.config.host, self.config.port);
		let listener = TcpListener::bind(addr)?;
		listener.set_nonblocking(true)?;

		let sleep_time = Duration::from_millis(1);
		loop {
			match listener.accept() {
				Ok((stream, peer_addr)) => {
					if !self.check_banned(&stream) {
						if let Err(e) = self.handle_new_peer(stream) {
							warn!(
								LOGGER,
								"Error accepting peer {}: {:?}",
								peer_addr.to_string(),
								e
							);
						}
					}
				}
				Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => {
					// nothing to do, will retry in next iteration
				}
				Err(e) => {
					warn!(LOGGER, "Couldn't establish new client connection: {:?}", e);
				}
			}
			if self.stop.load(Ordering::Relaxed) {
				break;
			}
			thread::sleep(sleep_time);
		}
		Ok(())
	}
/// Starts a new TCP server and listen to incoming connections. This is a
/// blocking call until the TCP server stops.
Starts a new TCP server and listen to incoming connections. This is a
blocking call until the TCP server stops.
Starts a new TCP server and listen to incoming connections . This is a blocking call until the TCP server stops .
pub fn listen(&self) -> Result<(), Error> {
		// start TCP listener and handle incoming connections
		let addr = SocketAddr::new(self.config.host, self.config.port);
		let listener = TcpListener::bind(addr)?;
		listener.set_nonblocking(true)?;
		let sleep_time = Duration::from_millis(1);
		loop {
			match listener.accept() {
				Ok((stream, peer_addr)) => {
					if !self.check_banned(&stream) {
						if let Err(e) = self.handle_new_peer(stream) {
							warn!(
								LOGGER,
								"Error accepting peer {}: {:?}",
								peer_addr.to_string(),
								e
							);
						}
					}
				}
				Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => {
					// nothing to do, will retry in next iteration
				}
				Err(e) => {
					warn!(LOGGER, "Couldn't establish new client connection: {:?}", e);
				}
			}
			if self.stop.load(Ordering::Relaxed) {
				break;
			}
			thread::sleep(sleep_time);
		}
		Ok(())
	}
pub fn listen ( & self ) -> Result < ( ) , Error > { // start TCP listener and handle incoming connections let addr = SocketAddr :: new ( self . config . host , self . config . port ) ; let listener = TcpListener :: bind ( addr ) ? ; listener . set_nonblocking ( true ) ? ; let sleep_time = Duration :: from_millis ( 1 ) ; loop { match listener . accept ( ) { Ok ( ( stream , peer_addr ) ) => { if ! self . check_banned ( & stream ) { if let Err ( e ) = self . handle_new_peer ( stream ) { warn ! ( LOGGER " " peer_addr to_string ( ) e ) ; } } } Err ( ref e ) if e . kind ( ) == io :: ErrorKind :: WouldBlock => { // nothing to do, will retry in next iteration } Err ( e ) => { warn ! ( LOGGER " " e ) ; } } if self . stop . load ( Ordering :: Relaxed ) { break ; } thread :: sleep ( sleep_time ) ; } Ok ( ( ) ) }
Starts a new TCP server and listen to incoming connections.
Starts a new TCP server and listen to incoming connections .
&self