This document introduces the design of the GGZ server (ggzd) and explains how it works. Additional reading is suggested in the GGZ Gaming Zone Database document and the GGZ Hosting Guide.
The GGZ Gaming Zone server, named ggzd, is a Unix daemon written in C. It handles connections from (GGZ) clients in multiple threads, and launches games as external processes, with whom it also keeps a connection. Data received from either the clients or the game servers is passed to the other connection and/or stored in its database.
It consists of multiple subsystems and links statically to two libraries which are also used by other programmes: the database abstraction library, used by ggzduedit to manually manipulate player entries, and the game server communication library ggzdmod, used also by the games themselves. Further dependencies are libggz, expat for the XML protocol handling, and popt to handle command line arguments. Optionally, howl can be included to announce its service on a local network, where it can be detected by a GGZ core client.
The database can either be embedded or running as an external process, even on another host. The connections to the clients and to the game servers are always using TCP/IP.
When ggzd starts up, it will read command line arguments first, and configuration files second. Depending on the configuration, a message of the day file (MOTD) as well as the game rooms and game type description files will be read in. It will then open the log files, and fork itself into the background. There are still some smaller tasks to do before the service can be activated: It announces the service to the LAN (optional), initializes its TLS library wrapper (optional), and binds to the configured port. From then on, clients are able to connect.
During the connection period of a client, there are a number of events which can occur. The first one is to handle the login procedure, which might require player authentication or registration. The second is to handle player room changes and chat messages. The third is to handle games, which means launching a game server, putting the player (and all those who join) at the table, and receive the game result afterwards, which might involve storing them into the database.