1996-11-27 15:52:01 -04:00
|
|
|
#! /usr/bin/env python
|
1991-09-15 18:05:15 -03:00
|
|
|
|
|
|
|
# unicast host [port]
|
|
|
|
#
|
|
|
|
# Similar to "broadcast.py" but sends to a specific host only;
|
|
|
|
# use "radio.py" on the designated host to receive.
|
|
|
|
# This is less stressful on other hosts on the same ethernet segment
|
|
|
|
# if you need to send to one host only.
|
|
|
|
|
|
|
|
import sys, al
|
|
|
|
from socket import *
|
|
|
|
|
|
|
|
host = sys.argv[1]
|
|
|
|
|
1992-12-14 11:05:53 -04:00
|
|
|
port = 5555
|
1991-09-15 18:05:15 -03:00
|
|
|
if sys.argv[2:]: port = eval(sys.argv[1])
|
|
|
|
|
|
|
|
s = socket(AF_INET, SOCK_DGRAM)
|
|
|
|
|
|
|
|
p = al.openport('unicast', 'r')
|
|
|
|
|
|
|
|
address = host, port
|
|
|
|
while 1:
|
|
|
|
# 700 samples equals 1400 bytes, or about the max packet size!
|
|
|
|
data = p.readsamps(700)
|
|
|
|
s.sendto(data, address)
|