summaryrefslogtreecommitdiffstats
path: root/tcllib/examples/tie/receiving_client.tcl
blob: c41d9d342513959bc23e3928a3759e0ac9c1da6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env tclsh
## -*- tcl -*-

package require comm
package require tie

set id [lindex $argv 0]

proc import {remotevar localvar} {
    global id
    comm::comm send $id [list \
	    tie::tie $remotevar remotearray \
	    $localvar {comm::comm send} [comm::comm self] \
	 ]
}

proc Track {args} {
    global receiver
    puts *\ \[[join $args "\] \["]\]\ ([dictsort [array get receiver]])
    return
}

proc dictsort {dict} {
    array set a $dict
    set out [list]
    foreach key [lsort [array names a]] {
	lappend out $key $a($key)
    }
    return $out
}

array set          receiver {}
trace add variable receiver {write unset} Track

import server receiver

puts "Waiting on $id"
vwait forever