somethingctl over unix sockets
From: Dacav Doe <dacav@tilde.institute>
Reply to: Dacav Doe
Date: Wed, 13 May 2020 11:30:33 -0000 (UTC)
Organization: tilde.club
Newsgroups:
tilde.projects
Followup to: newsgroup
Dear associates,
It's not uncommon under *nix to have a "somethingctl(1)" command asssociated >with a "something(8)" daemon, so that you can interact with a running daemon to
achieve some administration task.
This kind of interface is often (but not necessarily) implemented by means of a
UNIX socket, which is what I'd like to use for the little daemon I'm writing.
UNIX sockets are usually[1] nice to work with, but they're somewhat ...raw. >Sure, one can implement a parser and just interpret commands in form of >strings, but it would be so handy to have some pre-baked protocol for it >instead! Something that allows to encode simple commands with parameters.
I searched on the WEBS but it looks like all viable alternatives are either >some XML bullshit, or stuff like DBUS.
I never worked with any of them but:
- if there's XML in the name, it must be evil.
- DBUS, where do I start? It comes from freedesktop.org, the "D" stands for >Desktop, if the length of the wikipedia is proportional to its complexity, I >would not touch it with a stick.
Or zeromq! Which is super nice to work with, but a bit of an overkill in my >case, and way too opinionated about event-loops, threading and such.
Well, I'm currently writing a *simple* protocol, with no intention whatsoever >of turning it into a stand-alone project later on. But I wonder how other >people would have done it.
What would you do in my situation?
[1] Except if you're trying to do something crazy, like sending a file >descriptor: the API gets awkward there!
dacav--
Maybe something like POSIX message queues?
man 7 mq_overview
https://linux.die.net/man/7/mq_overview
Not sure about system compatability, though should be good beyond Linux 2.6.6.
UNIX sockets are usually[1] nice to work with, but they're somewhat ...raw. Sure, one can implement a parser and just interpret commands in form of strings, but it would be so handy to have some pre-baked protocol for it instead! Something that allows to encode simple commands with parameters.
Sysop: | deepend |
---|---|
Location: | Calgary, Alberta |
Users: | 255 |
Nodes: | 10 (0 / 10) |
Uptime: | 127:20:41 |
Calls: | 1,718 |
Calls today: | 2 |
Files: | 4,099 |
D/L today: |
2 files (2,312K bytes) |
Messages: | 392,095 |