Staging
v0.5.1
https://github.com/python/cpython
Raw File
Tip revision: 1563f164e52d886d7f5ee7019bf176c8514b0243 authored by Benjamin Peterson on 11 June 2016, 21:46:26 UTC
2.7.12 release candidate 1
Tip revision: 1563f16
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