Last change
on this file since 50 was
50,
checked in by mmc, 19 years ago
|
Added support for file transfer with the desktop. Each Rappture
application acts like an http server, configured to listen on
a particular port according to the parameters found in the file
~/data/sessions/$SESSION/resources. When the server is active,
the GUI has a "Download..." button in the results area. A Java
client (in the filexfer directory) connects to the server and
listens for download requests. When the user clicks on "Download...",
the desired result is spooled to a file, and a Java client pops up
a web page requesting the file. This downloads the result to the
user's desktop.
Note that if the $SESSION environment variable is not set, these
changes do nothing.
|
File size:
1.3 KB
|
Line | |
---|
1 | # |
---|
2 | # Use this to test the HTTP protocol. Start this server, |
---|
3 | # then treat localhost:9001 as a web site, and watch the |
---|
4 | # traffic between the client and the web server at localhost:80 |
---|
5 | # |
---|
6 | set port 80 |
---|
7 | if {[llength $argv] > 0} { |
---|
8 | set port [lindex $argv 0] |
---|
9 | } |
---|
10 | |
---|
11 | set client "" |
---|
12 | set server "" |
---|
13 | |
---|
14 | proc accept {cid addr port} { |
---|
15 | global client |
---|
16 | fileevent $cid readable [list client_handler $cid] |
---|
17 | fconfigure $cid -buffering line |
---|
18 | set client $cid |
---|
19 | } |
---|
20 | |
---|
21 | proc client_handler {cid} { |
---|
22 | global client server port |
---|
23 | if {[gets $cid line] < 0} { |
---|
24 | close $cid |
---|
25 | set client "" |
---|
26 | } else { |
---|
27 | if {$server == ""} { |
---|
28 | set server [socket localhost $port] |
---|
29 | fileevent $server readable [list server_handler $server] |
---|
30 | fconfigure $server -buffering line |
---|
31 | } |
---|
32 | puts "CLIENT: $line" |
---|
33 | puts $server $line |
---|
34 | flush $server |
---|
35 | } |
---|
36 | } |
---|
37 | |
---|
38 | proc server_handler {sid} { |
---|
39 | global client server |
---|
40 | if {[gets $sid line] < 0} { |
---|
41 | close $sid |
---|
42 | set server "" |
---|
43 | } else { |
---|
44 | if {[regexp {[\000-\006\016-\037\177-\400]} $line]} { |
---|
45 | puts "SERVER: --[string length $line] bytes--" |
---|
46 | } else { |
---|
47 | puts "SERVER: $line" |
---|
48 | } |
---|
49 | catch {puts $client $line} |
---|
50 | catch {flush $client} |
---|
51 | } |
---|
52 | } |
---|
53 | |
---|
54 | socket -server accept 9001 |
---|
55 | vwait forever |
---|
Note: See
TracBrowser
for help on using the repository browser.