【问题标题】:How to send data using Python-Zeroconf如何使用 Python-Zeroconf 发送数据
【发布时间】:2020-09-10 19:48:19
【问题描述】:

我看到了tutorial on Python-Zeroconf

本教程展示了如何创建 Python-Zeroconf 侦听器,因此我知道如何接收数据。

这是下面。

from zeroconf import ServiceBrowser, Zeroconf

class MyListener:

    def remove_service(self, zeroconf, type, name):
        print("Service %s removed" % (name,))

    def add_service(self, zeroconf, type, name):
        info = zeroconf.get_service_info(type, name)
        print("Service %s added, service info: %s" % (name, info))


zeroconf = Zeroconf()
listener = MyListener()
browser = ServiceBrowser(zeroconf, "_http._tcp.local.", listener)
try:
    input("Press enter to exit...\n\n")
finally:
    zeroconf.close()

但是好像没有写怎么发送数据。是否可以使用 Python-Zeroconf 发送数据?如何发送?

【问题讨论】:

    标签: python zeroconf


    【解决方案1】:

    Zeroconf 是关于让客户端找到服务以及连接到哪个端口,而不是实际的数据传输。 网上有关于在 python 中创建简单的客户端和服务器的教程。 这是一个Python socket programming

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-05-11
      • 1970-01-01
      • 1970-01-01
      • 2017-10-31
      • 2015-07-11
      • 2019-05-07
      • 2017-04-13
      • 2020-10-09
      相关资源
      最近更新 更多