I'm developing a small card game, based on a client-server solution. I have only touched lighly on network programming previously, covering the basics, and have now come across a few questions. Perhaps you can help me sort them out.
I'm developing this in C#, becuase I want to learn a new language, although I'm not looking for any language specific answers or code examples. Rather, my questions is more about the general client-server interaction, and how to handle multiple clients.
Currently, I've made a server which can be connected to by multiple clients (there is still no client though, I've been testing using telnet), after which it asks for a username and stores the connected user in a list. The idea is that the client, while in this "lounge area" (in lack of a better description) should be able to see all connected users and available games. A game can then either be joined or the client can create a new game and let others join that.
1. Each client needs an updated list of available games and players. Should the client periodically ask the server for this, or should the server supply it upon connection and keep sending updates as the list changes?
2. The server needs to be able to remove inactive connections/clients (e.g. if a client crashes), but how can it keep track of them? Should the server periodically ask each client weather they're still alive or not, or should the client periodically announce that it is still alive, in which case the server assumes they're dead if they do not? Or is there another way?
3. Regarding both question 1 and 2, if the server is to periodically send data to all clients, is there any smarter way of doing so than to just loop through them all and send the same data through all sockets? That seems a bit ineffective to me. Sure, it won't matter unless there is alot of clients, but what if there is?
And I could swear there was something more I wanted to ask, but I can't recall what. Oh, well.
I'll be thankful for any help you can provide.
Your answers will only be as good as your question. Formulate it well and give all the necessary information.