c++ - Non-blocking user input for commands in server application -
How the user can command input that will not block the application loop. As it is done in the game server, admin-user can press the players by issuing the console command or remove the eggs.
I have read that I can make it by creating a new thread for it. But if I do, then call it, the input thread which will block from std :: cin
, and then the main thread will end, due to the input thread std :: cin is not included Will be
blocking.
If there is a way to kill such input thread, when the main thread is going back - this would be my preferred solution but I think there is no such way, or if it exists, So it is not safe or secure.
In addition to that I have read about the implementation of the file descriptor set and the basis of the select
function, but it does not work on Windows.
It would be great if the solution would not require me to control the arrow, backspace, delete and encode.
Comments
Post a Comment