Updated for 2.1a3
[python/dscho.git] / Demo / sgi / al / unicast.py
blob0d537b180f7840b796cd54f94c9a97a105f25294
1 #! /usr/bin/env python
3 # unicast host [port]
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.
10 import sys, al
11 from socket import *
13 host = sys.argv[1]
15 port = 5555
16 if sys.argv[2:]: port = eval(sys.argv[1])
18 s = socket(AF_INET, SOCK_DGRAM)
20 p = al.openport('unicast', 'r')
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)