RpcPeer(3I)
π RpcPeer(3I) π
the InterViews manual page, but make it a group chat β okay bestie, this one lives in the InterViews Reference Manual, and it's literally the blueprint for letting two services talk to each other both ways. No cap.
β¨ NAME β¨
RpcPeer β support bi-directional RPC between two services π«Ά
πΈ SYNOPSIS πΈ
#include <Dispatch/rpcpeer.h>
π¦ DESCRIPTION π¦
So here's the vibe. An RpcPeer β and honestly it's really an instance of a derived class, not the base one, more on that in a sec β tries to open a connection to another RpcPeer.
But what if the other one isn't up yet? π Not a problem. If the other RpcPeer isn't running, our RpcPeer will create its own port and just... wait. Patient queen behavior. π
Then, the moment either RpcPeer opens a connection, each RpcPeer creates both a reader and a writer. Which means each side can send RPC requests to its opposite over the same connection. Bi-directional. Mutual. Iconic. β¨
π CONSTRUCTOR π
RpcPeer(const char* lPath, int lPort = 0)β this one just stores the arguments for later use, because a base constructor literally can't call a derived class's virtual function (the way that C++ works, iykyk π). The derived class's constructor should callinit, described right below.void init(const char* rPath)β find the host name and port number that the otherRpcPeerregistered, then try to open a connection to it. And if it's not running? Create our own port and wait for the otherRpcPeerto open a connection. π¦
π PUBLIC OPERATIONS π
void run()void quitRunning()
Read RPC requests continuously until quitRunning() terminates the loop. π
bestie PSA: if you're using InterViews, you do not have to call run() β the InterViews event-reading code will also read RPC requests for you. So don't do extra work for no reason, okay? π
π₯ PROTECTED OPERATIONS π₯
virtual boolean createReaderAndWriter(const char* rHost, int rPort) = 0virtual void createReaderAndWriter(int fd) = 0
You must define both of these functions in a derived class in order to start reading and writing RPC requests over the connection. Both of them, no skipping. π¨
Typically both functions would create a writer using the given parameters, and then attach a reader to the writer's rpcstream. That's the whole move. Periodt. π
π SEE ALSO π
Dispatcher(3I)RpcReader(3I)RpcRegistry(3I)RpcWriter(3I)
okay that's the whole page, go forth and connect some services π
β§ο½₯οΎ sign-off qο½₯οΎβ§ this gem came from InterViews, dated 27 March 1991 β yes, she's vintage, and she still ate. ππ¦β¨
π¦ where this page comes from
- debian bookworm: ivtools-dev 2.0.11d.a1-1+b4
- debian trixie: ivtools-dev 2.0.11d.a1-3+b4
- ubuntu jammy: ivtools-dev 2.0.11d.a1-1build1
- ubuntu noble: ivtools-dev 2.0.11d.a1-3build1
- ubuntu questing: ivtools-dev 2.0.11d.a1-3build7
- ubuntu resolute: ivtools-dev 2.0.11d.a1-3build9
- ubuntu stonking: ivtools-dev 2.1.1+git.2025.07.26.a1-1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms