Programming Distributed Systems with YAMI4
6.1 Listeners
Each agent can manage zero or more listeners.
The listener represents the connection target for remote agents and in the case of TCP is associated with a physical listening socket.
Listeners can be added to and removed from the existing agent at any time.
A typical server program creates one or more listeners during its initialization phase. After that, it is ready to accept incoming connections, which is automatically handled by the agent.
Purely client-oriented programs do not need to create any listeners.
Listeners are identified by their resolved target names, which are generated when the listener is created.
The resolved name can be generated at creation time based on the addressing information obtained from the operating system and in some cases can be different than the name that was provided by user code. This possibility influences the way clients get to know about connection points in respective servers and in practice two possible approaches can be identified:
- Deterministic target resolution. The listener target is constructed in such a way that the operating system has no freedom to choose any of its components. In the case of TCP listeners, if the local address and port number are provided by user code, the resolved target name will be the same as the given one. With this approach, there is no reason for the server to announce its resolved listener targets, because it will be always the same - in other words, clients can just assume that the given target is always correct. Well-known services and central servers in the distributed system can use this strategy for defining their targets.
- On-demand target resolution. The listener target provided by the user code can allow some freedom of choice for the operating system and in effect lead to different actual targets when the listener is finally established. In the case of TCP listeners, it is possible for the server program to let the operating system choose the port number for the listening socket. This is appropriate for temporary or transient servers, but this approach has to also rely on the existence of some additional information channel for announcing the resolved listener target to interested clients. Practical approaches range from file sharing or common databases to full-featured directory services.
Note:
To allow users experiment with different listener formats, all example programs that are provided with the YAMI4 distribution use a common convention where server programs print their resolved target names to their standard output and client programs expect the target as their first parameter.
6.1.1 TCP Listeners
6.1.2 SSL Listeners
6.1.3 UDP Listeners
6.1.4 Unix Listeners
6.1.5 Ada
6.1.6 C++
6.1.7 Java
6.1.8 .NET
6.1.9 Python