如何使用Python在不同网络上的两个设备上共享屏幕



我有一个脚本,可以在python中在同一网络上共享屏幕,但我希望能够在不同的网络上共享。有人能告诉我怎么做吗?

我的receiver.py代码是:

from vidstream import StreamingServer
import threading
receiver = StreamingServer('127.0.0.1', 9999)
t = threading.Thread(target=receiver.start_server)
t.start()
while input("") != 'STOP':
continue
receiver.stop_server()

我的client.py(我正在查看的PC(代码是:

from vidstream import ScreenShareClient
import threading
sender = ScreenShareClient('127.0.0.1', 9999)
t = threading.Thread(target=sender.start_stream)
t.start()
while input("") != 'STOP':
continue
receiver.stop_server()

您需要将IP地址从环回地址更改为本地网络上的IP,然后在路由器中转发这些端口。

由于192.168.x.x(C类IP地址(经常被家庭网络使用,我们将以以下IP为例,但您可以通过linux上的ifconfig或windows中的ipconfig找到这一点。

StreamingServer('192.168.2.1', 9999)

->转发路由器和/或防火墙中的端口。

->查找您的公共IP(https://whatsmyip.org)

然后在您的客户端上,输入您的公共IP和连接到服务器的端口:

ScreenShareClient('YOUR_PUBLIC_IP', 9999)

最新更新