import socket, sys dest = ('', 51423) s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST,1) s.sendto("Hi", dest) print "Looking for replies; press Ctrl-C to stop." while 1: (buf, address) = s.recvfrom(2048) if not len(buf): break print "Received from %s: %s" % (address, buf)
希望本文所述对大家的Python程序设计有所帮助。
声明:本网页内容旨在传播知识,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。TEL:177 7030 7066 E-MAIL:11247931@qq.com