Additionally, it can be used as a fast IPC mechanism to allow applications to receive events immediately instead of using the fork/exec model of event handlers.
I'm not able to figure out how to receive events and queries
Short answer: You send a "stream" command and subsequently get matching events and queries until you send "stop" (or close the connection of course). https://www.serf.io/docs/agent/rpc.html#stream
You respond to queries using, surprise, a "respond" command.
Which programming language? if Python,
https://github.com/smurfix/trio-serf implements all of this in a
-- -- mit freundlichen Grüßen -- -- Matthias Urlichs