socket_server

Crates.iosocket_server
lib.rssocket_server
version0.12.0
sourcesrc
created_at2024-07-18 15:58:39.075836
updated_at2024-08-06 07:07:40.210647
descriptionsocket write event polling registration avoiding syscall
homepage
repositoryhttps://github.com/Bruce0203/fast_collections
max_upload_size
id1307635
size28,121
(Bruce0203)

documentation

README

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!()
    }
}
Commit count: 0

cargo fmt