Crates.io | socket_server |
lib.rs | socket_server |
version | 0.12.0 |
source | src |
created_at | 2024-07-18 15:58:39.075836 |
updated_at | 2024-08-06 07:07:40.210647 |
description | socket write event polling registration avoiding syscall |
homepage | |
repository | https://github.com/Bruce0203/fast_collections |
max_upload_size | |
id | 1307635 |
size | 28,121 |
example
use std::time::Duration;
use qcell::LCellOwner;
use socket_server::{
selector::listen,
socket::{ServerSocketListener, Socket},
};
fn main() {
LCellOwner::scope(|mut owner| listen(&mut owner, GameServer, "[::]:0"));
}
pub struct GameServer;
#[derive(Default)]
pub struct Player {}
impl<'id> ServerSocketListener<'id> for GameServer {
const MAX_CONNECTIONS: usize = 10;
const READ_BUFFFER_LEN: usize = 100;
const WRITE_BUFFER_LEN: usize = 100;
const TICK: Duration = Duration::from_millis(50);
type Connection = Player;
fn tick(&mut self, owner: &mut LCellOwner<'id>) {
todo!()
}
fn accept(&mut self, owner: &mut LCellOwner<'id>, connection: &mut Socket<'id, '_, Self>) {
todo!()
}
fn read(&mut self, owner: &mut LCellOwner<'id>, connection: &mut Socket<'id, '_, Self>) {
todo!()
}
fn flush(&mut self, owner: &mut LCellOwner<'id>, connection: &mut Socket<'id, '_, Self>) {
todo!()
}
fn close(&mut self, owner: &mut LCellOwner<'id>, connection: &mut Socket<'id, '_, Self>) {
todo!()
}
}