如何使用Python-Zeroconf发送数据

问题描述

我看到了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,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发送数据?我该如何发送?

解决方法

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