From: David B. <dav...@gm...> - 2011-02-01 17:28:40
|
Hi, On Tue, Feb 1, 2011 at 10:58 AM, deepak aggarwal <dee...@gm...> wrote: >>At least for me, I would just like to be able to support more than one >>network game at a time from a single machine, eventually. Most likely >>this will be a single server program that can handle multiple >>simultaneous games. Whether or not it involves a separate thread for >>each game is not essential, likewise we may or may not open a separate >>port for each game. I guess running multiple instances of the same >>program on the same machine is another possibility, if we work out a >>way to assign all the ports correctly. > >> David > > I am trying to implement exactly this thing :- Which one? I see you want to open a separate port for each game. Do you want to have a single instance of the server program be able to handle multiple simultaneous games and if so, are you going to spawn a separate thread for each one, or use an old-style fork() call? Or, is a separate program going to be launched to handle each game? > Please send me email address so that i can send files to you. This is going to be much better handled with a (remote) git branch. You need to know how to use git to contribute to our project. So, go to our alioth website, ask to be added to the tux4kids project, and make a "read/write" clone of the tuxmath repository. Then you can make your branch and start working in a way that lets all of us test out and help with your work. > Is there anyone who can send me short outline of how server is > implemented so that i can avoid unnecessary things and able to > understand things more correctly. The server code is in server.c. It is written so it can be invoked either in a pthread or as a standalone program. For the latter, servermain.c contains a small main() function that calls the RunServer() function from server.c (with some init and cleanup). RunServer() contains the main loop for the server. To let the clients connect, RunServer() sends out periodic UDP broadcasts. The clients respond by sending back the information needed to establish a TCP connection. Once connected, the server listens for incoming messages and responds with appropriate outgoing messages. The incoming messages are mainly about math questions that have been answered. The outgoing messages are new questions and other notifications (new wave, names and scores of connected players, game over, etc). The clients disconnect from the server when the game ends. Once the game is over, the server is supposed to be ready to accept connections to start a new game. The client network code is in network.c and game.c for the full graphical game. There is also a command-line client in testclient.c, but last I checked it isn't working. We probably should get the testclient working again if we are going to do a lot of work on the server program. Hope that helps, David Bruce |