How to get "server console"
I would like to write a server application which has a read in of the users commands but still outputting new events during the read in. It should look like e.g. the Minecraft server开发者_如何学JAVA console. I tried some things but nothing worked and I'm out of ideas.
Check out
http://www.amazon.com/Pocket-Socket-Programming-Kaufmann-Practical/dp/1558606866
This is a great guide to learning sockets.
I would look start with the very simple TCP Listener example in the book.
You'll want your server to listen to a socket, read (parse) user commands, and respond accordingly.
If you're not tied to C++, you can do this pretty darn quickly with a Perl/Python/Ruby or even C#.
Read about libedit or GNU Readline.
精彩评论