python 来自http://stackoverflow.com/questions/22878625/receiving-broadcast-packets-in-python

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 来自http://stackoverflow.com/questions/22878625/receiving-broadcast-packets-in-python相关的知识,希望对你有一定的参考价值。

'''
A simple implementation of broadcast of packets in python 

send.py -> How packets are broadcasted
receive.py -> How broadcasts are received 

'''


from socket import *
s=socket(AF_INET, SOCK_DGRAM)
s.setsockopt(SOL_SOCKET, SO_BROADCAST, 1)
s.sendto('this is testing',('255.255.255.255',12345))
from socket import *
s=socket(AF_INET, SOCK_DGRAM)
s.bind(('',12345))
m=s.recvfrom(1024)
print m[0]

以上是关于python 来自http://stackoverflow.com/questions/22878625/receiving-broadcast-packets-in-python的主要内容,如果未能解决你的问题,请参考以下文章

python 来自Python的Git pull

python 来自Python的os文件系统

一封来自“Python”的信

来自 Black Hat Python 书的 Python 嗅探

“路径 python3(来自 --python=python3)不存在”错误

python Python装饰模板(来自“Head First Python ed.2”)