Guido van Rossum | f06ee5f | 1996-11-27 19:52:01 +0000 | [diff] [blame] | 1 | #! /usr/bin/env python |
Guido van Rossum | 50692d6 | 1991-09-15 21:05:15 +0000 | [diff] [blame] | 2 | |
| 3 | # unicast host [port] |
| 4 | # |
| 5 | # Similar to "broadcast.py" but sends to a specific host only; |
| 6 | # use "radio.py" on the designated host to receive. |
| 7 | # This is less stressful on other hosts on the same ethernet segment |
| 8 | # if you need to send to one host only. |
| 9 | |
| 10 | import sys, al |
| 11 | from socket import * |
| 12 | |
| 13 | host = sys.argv[1] |
| 14 | |
Guido van Rossum | a8413b2 | 1992-12-14 15:05:53 +0000 | [diff] [blame] | 15 | port = 5555 |
Guido van Rossum | 50692d6 | 1991-09-15 21:05:15 +0000 | [diff] [blame] | 16 | if sys.argv[2:]: port = eval(sys.argv[1]) |
| 17 | |
| 18 | s = socket(AF_INET, SOCK_DGRAM) |
| 19 | |
| 20 | p = al.openport('unicast', 'r') |
| 21 | |
| 22 | address = host, port |
| 23 | while 1: |
| 24 | # 700 samples equals 1400 bytes, or about the max packet size! |
| 25 | data = p.readsamps(700) |
| 26 | s.sendto(data, address) |