Interprocess Communication (IPC) · Message Handlers (.z Namespace) · Practice Question
What Are the .z Message Handlers?
Question
A q process exposes a small set of built-in callback functions in the .z namespace that fire at specific points during an IPC connection's life. What are the main ones involved in opening a connection and handling incoming requests, and what does each one do?
Solution
| Handler | Fires when... |
|---|---|
.z.pw | a username/password needs validating, before a connection is accepted |
.z.po | a connection has just been opened (after validation succeeds) |
.z.pg | a synchronous ("get") request arrives over an open connection |
.z.ps | an asynchronous ("set") request arrives over an open connection |
.z.pc | a connection closes |
Explanation
These five cover a connection's full lifecycle: validate (.z.pw) → open (.z.po) → handle requests (.z.pg sync / .z.ps async) → close (.z.pc).
q ships a working default for each, so a process that never touches .z still behaves correctly. Overriding one — .z.pg, say — lets a process log, reject, or check incoming requests before evaluating them, with no change needed on the calling side.
The naming follows "get vs set": .z.pg handles requests expecting something back, .z.ps handles fire-and-forget ones — mirroring the sync/async split exactly.