As a learning exercise i am trying to reproduce a C++ intervew i had a while ago, in rust.
The idea is to develop a TCP server that can accept 4 TCP connections and send them a unique identifier every second, this identifier computation being "performance sensitive" (IDs must be unique across clients). If ctrl-C is pressed on the server, it must send "goodbye" to each client and gracefully close connections.
My main interrogation is about the handling of ctrl-c :
I guess i could simply have a shared boolean and provide it to the 4 threads so they periodically check its value, but is there a more "standard" way of doing this in rust ? Reading about channels and selects for instance made me think there might be a better design but i can't figure out what it would look like for now. Since it is mainly to learn rust i am not using framework such as tokio for instance but i use the ctrlc crate.
Do you have any suggestion on the overrall design ?