Back to Message Handlers (.z Namespace)

Interprocess Communication (IPC) · Message Handlers (.z Namespace) · Practice Question

What Are the .z Message Handlers?

Sign in to track your progress

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

HandlerFires when...
.z.pwa username/password needs validating, before a connection is accepted
.z.poa connection has just been opened (after validation succeeds)
.z.pga synchronous ("get") request arrives over an open connection
.z.psan asynchronous ("set") request arrives over an open connection
.z.pca 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.