连接到另一台计算机上的会话DBus [英] Connect to session DBus on different computer

查看:258
本文介绍了连接到另一台计算机上的会话DBus的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以通过连接到会话总线来运行Qt DBus测试:

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

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

但是我可以从另一台计算机连接到此DBus吗?我知道我可以做这样的事情:

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);

但是我将如何获取端口?无论我尝试了什么,似乎都没有任何联系。还是我在这里走错了路,需要我们Peer 2 Peer DBus而不是会话总线?

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?

我几乎可以确定服务名称是正确的,因为我可以在 qdbusviewer 中看到它。当我使用 dbus-monitor 时,输出对我来说意义不大,看不到任何端口,等等。

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.

有人知道我将如何从另一台计算机进行连接吗?

PS:我知道有类似gabriel的东西可用于隧道传输通过SSH( http://gabriel.sourceforge.net/howto.html )。这不是不是,我正在寻找直接连接。

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".

推荐答案

会话总线守护进程通常会监听Unix套接字 / var / run / dbus / system_bus_socket (检查您的 / usr / local / etc / dbus-1 / session .conf config),这意味着您无法通过tcp远程访问它。在运行总线守护程序的计算机上启动某种端口转发(例如,使用 socat )或将其配置为侦听tcp。

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.

这篇关于连接到另一台计算机上的会话DBus的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆