Staging
v0.5.1
https://github.com/python/cpython
Raw File
Tip revision: 377510d2d9e6cb111383e124f753c73b571e577b authored by Benjamin Peterson on 11 June 2011, 14:50:21 UTC
update pydoc-topics
Tip revision: 377510d
radio.py
# Receive UDP packets transmitted by a broadcasting service

MYPORT = 50000

import sys
from socket import *

s = socket(AF_INET, SOCK_DGRAM)
s.bind(('', MYPORT))

while 1:
    data, wherefrom = s.recvfrom(1500, 0)
    sys.stderr.write(repr(wherefrom) + '\n')
    sys.stdout.write(data)
back to top