pyp2p 库 - 如何使用 pyp2p 库进行点对点通信
谁能告诉我如何使用 pyp2p 库进行点对点通信。或者是否有其他方法可以连接到位于 2 个不同 NAT 后面的 2 台不同计算机
Alice Node
from pyp2p.net import *
import time
#Setup Alice's p2p node.
alice = Net(passive_bind="192.168.0.45", passive_port=44444, interface="eth0:2", node_type="passive", debug=1)
alice.start()
alice.bootstrap()
alice.advertise()
#Event loop.
while 1:
for con in alice:
for reply in con:
print(reply)
time.sleep(1)
我必须在 Passive_bind、passive_port 和接口下输入什么,才能在位于 2 个不同 NAT 后面的两个节点之间建立连接
Bob Node
from pyp2p.net import *
#Setup Bob's p2p node.
bob = Net(passive_bind="192.168.0.44", passive_port=44445, interface="eth0:1", node_type="passive", debug=1)
bob.start()
bob.bootstrap()
bob.advertise()
#Event loop.
while 1:
for con in bob:
con.send_line("test")
time.sleep(1)
Can anyone please tell me how to use the pyp2p library for peer to peer communication. Or is there any other way to connect to 2 different computers which are behind 2 different NATs
Alice Node
from pyp2p.net import *
import time
#Setup Alice's p2p node.
alice = Net(passive_bind="192.168.0.45", passive_port=44444, interface="eth0:2", node_type="passive", debug=1)
alice.start()
alice.bootstrap()
alice.advertise()
#Event loop.
while 1:
for con in alice:
for reply in con:
print(reply)
time.sleep(1)
What must I enter under passive_bind, passive_port and interface to establish connection between the two nodes which are behind 2 different NATs
Bob Node
from pyp2p.net import *
#Setup Bob's p2p node.
bob = Net(passive_bind="192.168.0.44", passive_port=44445, interface="eth0:1", node_type="passive", debug=1)
bob.start()
bob.bootstrap()
bob.advertise()
#Event loop.
while 1:
for con in bob:
con.send_line("test")
time.sleep(1)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论