Guido van Rossum | b83ec8f | 1992-05-19 13:52:02 +0000 | [diff] [blame] | 1 | # Receive UDP packets transmitted by a broadcasting service |
| 2 | |
| 3 | MYPORT = 50000 |
| 4 | |
| 5 | import sys |
| 6 | from socket import * |
| 7 | |
| 8 | s = socket(AF_INET, SOCK_DGRAM) |
Guido van Rossum | 00d5974 | 1994-10-08 19:13:48 +0000 | [diff] [blame] | 9 | s.bind(('', MYPORT)) |
Guido van Rossum | b83ec8f | 1992-05-19 13:52:02 +0000 | [diff] [blame] | 10 | |
| 11 | while 1: |
Guido van Rossum | d55f4d1 | 1993-12-17 14:39:12 +0000 | [diff] [blame] | 12 | data, wherefrom = s.recvfrom(1500, 0) |
| 13 | sys.stderr.write(`wherefrom` + '\n') |
Guido van Rossum | b83ec8f | 1992-05-19 13:52:02 +0000 | [diff] [blame] | 14 | sys.stdout.write(data) |