“Sending messages on a monitor connection is not allowed” – The Spec
Prevents dbus-monitor from sending messages after it became a monitor by disabling automatic responses to messages with the
org.freedesktop.DBus.Peer interface. This is a straight-forward implementation of @smcv’s suggestion.
I had no luck implementing a working unit test starting from this snippet in
test/monitor.c and would happily take a hint:
m = dbus_message_new_method_call (NULL, "/", "org.freedesktop.DBus.Peer", "Ping"); dbus_connection_send (f->sender, m, NULL); dbus_message_unref (m);