Rustbound / Server field manual 02
One World, Many Players
One owner.
Many connections.
The first Rustbound game lived in one process. Now Bryce, Ryan and Tommy all expect the same world to answer them at once—without copying it, corrupting it or making everyone wait.
- Rust 2024
- TCP
- Ownership
- Channels
- Tokio
- 1 lessons
Optional: enable reading history below and mark lessons complete yourself. Three early Rustbound foundation marks unlock the server-level display; they are not the reading prerequisite, and visits never count.
Rustbound foundation Return to Rustbound →
- 01 / Make one rule work
- 02 / Keep state moving
- 03 / Give state a shape
for stream in listener.incoming() {
let stream = stream?;
let world = Arc::clone(&world);
thread::spawn(move || {
handle_player(stream, world);
});
}
Bench test / Nothing leaves this page
Make Ryan wait on purpose
Connect Bryce and Ryan with one blocking connection loop. Then switch the architecture and give each connection its own worker. The model is deterministic: it opens no socket and starts no thread.
With one blocking connection loop, Bryce's handler keeps the server from returning to accept(). Ryan's connection can wait in the operating system's listen queue, but the application does not read Ryan's command until Bryce leaves. When the accept loop delegates each connection to a worker, it can return to accept() immediately.
The connection log
Every lesson leaves the server working and gives the next problem somewhere concrete to appear.