cpython/Demo/sockets/radio.py

15 lines
287 B
Python
Raw Normal View History

1992-05-19 21:52:02 +08:00
# Receive UDP packets transmitted by a broadcasting service
MYPORT = 50000
import sys
from socket import *
s = socket(AF_INET, SOCK_DGRAM)
1994-10-09 03:13:48 +08:00
s.bind(('', MYPORT))
1992-05-19 21:52:02 +08:00
while 1:
data, wherefrom = s.recvfrom(1500, 0)
sys.stderr.write(repr(wherefrom) + '\n')
sys.stdout.write(data)