I can run my Qt DBus test by connecting to the session bus:

QDBusConnection connection = QDBusConnection::sessionBus();
connection.registerService(...)
....
TestserviceInterface testserviceInterface( .... , connection, &a);

But can I connect to this DBus from a different computer. I know I can do something like this:

 connection = QDBusConnection::connectToPeer("tcp:host=127.0.0.1,port=45000", Testservice::ServiceName);

But how would I obtain the port? Whatever I have tried, there seems to be no connection. Or am I at the wrong path here and need to us Peer 2 Peer DBus instead of the session bus?

I am almost sure the service name is correct, as I can see it qdbusviewer. When I use dbus-monitor the output does not mean a lot to me, I cannot see any port, etc.

Any idea how I would be able to connect from another computer?

PS: I am aware that there is something like gabriel for tunnelling via SSH (http://gabriel.sourceforge.net/howto.html). This is not what I am up to, I am looking for a "direct connection".

有帮助吗?

解决方案

Session bus daemon usually listens unix socket /var/run/dbus/system_bus_socket ( check your /usr/local/etc/dbus-1/session.conf config ) which means that you can't access it remotely via tcp. Start some kind of port forwarding on computer where bus daemon is running (using socat for example) or configure it to listen tcp.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top