Home

Tags

послать BROADCAST пакет, python

2010-03-22 python socket

Отправка

PORT = 50000

from socket import *
s = socket(AF_INET, SOCK_DGRAM)
s.setsockopt(SOL_SOCKET, SO_BROADCAST, 1)
s.sendto('hello', ('192.168.0.255', PORT))


Прием
PORT = 50000

from socket import *
s = socket(AF_INET, SOCK_DGRAM)
s.bind(('', PORT))
s.setsockopt(SOL_SOCKET, SO_BROADCAST, 1)
print s.recv(100)

comments powered by Disqus