2. gen_server Behaviour

2 gen_server Behaviour

This section is to be read with the gen_server(3) manual page in stdblib, where all interface functions and callback functions are described in detail.

2.1 Client-Server Principles

The client-server model is characterized by a central server and an arbitrary number of clients. The client-server model is used for resource management operations, where several different clients want to share a common resource. The server is responsible for managing this resource.

Figure 2.1: Client-Server Model

2.2 Example

An example of a simple server written in plain Erlang is provided in Overview. The server can be reimplemented using gen_server, resulting in this callback module:

登录查看完整内容