NN_REQREP(7)
π NN_REQREP β the request/reply protocol, bestie edition π
okay so this is nn_reqrep(7) from nanomsg 1.2.2, and it's literally the blueprint for making a bunch of stateless workers share the workload. no cap. let's get into it π«Ά
β¨ NAME β¨
nn_reqrep β the request/reply scalability protocol π
πΈ SYNOPSIS πΈ
#include <nanomsg/nn.h>
#include <nanomsg/reqrep.h>
that's it. two includes. iconic behavior honestly.
π¦ DESCRIPTION π¦
so the whole point of this protocol is to distribute the workload among multiple stateless workers. that's the vibe. that's the assignment. β¨
heads up bestie: request/reply applications should be stateless. like, actually. this is not a suggestion, this is the whole design.
and it's important β like, key β to include all the info you need to process the request inside the request itself. yes, including info about the sender or the originator of the request, if you need that to be able to respond. π
because here's the thing: sender information cannot be retrieved from the underlying socket connection. and there's two reasons, both real:
- first, transports like
IPCmay not have a firm notion of a message origin. like, the concept just isn't there. π - second, transports that do have some notion may not have a reliable one β a TCP disconnect might mean a brand new sender, or it might just mean a temporary loss in network connectivity. and you literally cannot tell which. π
so for this reason, sender information must be included by the application if it's required. the manpage says: allocating 6 randomly-generated bytes in the message for the lifetime of the connection is sufficient for most purposes. and if your app is longer-lived? an UUID is more suitable. π
π§ Socket Types π§
NN_REQβ the one you use to implement the client application that sends requests and receives replies. main character energy, obviously. πNN_REPβ the one you use to implement the stateless worker that receives requests and sends replies. the backbone fr fr. πͺ
π Socket Options π
NN_REQ_RESEND_IVLβ this option is defined on the fullREQsocket. if a reply isn't received within the specified amount of milliseconds, the request gets automatically resent. type of this option isint. default value is60000(that's 1 minute, bestie). β°π₯
β SEE ALSO β
nn_bus(7) nn_pubsub(7) nn_pipeline(7) nn_survey(7) nn_pair(7) nanomsg(7)
go read them all, they're all slay in their own way. πβ¨
π AUTHORS π
Martin Sustrik <sustrik@250bpm.com> β thank you for your service, king π«‘π
and that's the whole page!! this was nanomsg 1.2.2, dated 2026-01-16, and honestly? obsessed. go build something stateless and gorgeous. mwah ππβ¨
π¦ where this page comes from
- fedora 44: nanomsg-devel 1.2.2-2.fc44 Β· MIT
- fedora 44: nanomsg-devel 1.2.2-2.fc44 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms