~ubuntu-branches/ubuntu/vivid/gcl/vivid

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
catch { close $server }  
proc jany { args } {
    global me ;
    set me [lindex $args 0] ;
    fconfigure $me -blocking 0 ;
    fileevent $me readable "joke $me"
}

proc joke { sock } {
    if { [eof $sock] } {
	puts "at end"
	close $sock
	return ""
    }
    set it [read $sock]
    puts "<$it>"
    return
}

set server [socket -server jany 4008]

proc send { s } { global me ;
                 puts $me $s ;
                 flush $me }
proc r { } {global me ; read $me }