[REBOL] rugby type thing
From: ryancole::usa::com at: 26-May-2001 3:01
Here is that script I mentioned the other day that you wanted to see. It
works somewhat, still buggy--very much a work in progress and nothing fancy.
Still needs a port handling report system, to get reports (returned data)
back without waiting around. One neet idea I was implementing was named
orders so you can tell the incoming reports apart, as you could be getting
many back at the same time, same port.
Contrary to some the comments, there is no serial capability.
anyways here it is:
Title: "CAPN Command Accessable Parallel Net"
An instance of REBOL evaluates scripts sent by another instance.
Since the script communicates tcp or serial, the instances can
be located on another machine.
start rebol on two systems with tcp connectivity and do %capn.r
220.127.116.11 >> comply tcp://:6666
18.104.22.168 >> order tcp://22.214.171.124:6666 [ 1000 + 999 ]
126.96.36.199 == 1999
capn: make object! [
comply: function [
listen-url [url!] "TCP or Serial port to listen on."
rv ; return value
serving-port: open listen-url
connected-port: first serving-port
header: copy 
until [ (copy header) = append header load get-line connected-port ]
probe header: make object! header
if header/reconnect [ close connected-port ]
if error? rv: try [
mold assume-nothing do load copy/part connected-port header/size
rv: mold disarm rv
reply: rejoin [
length? rv "^/"
either header/reconnect [
reply-port: open header/report-to
insert reply-port reply
insert connected-port reply
order: function [
Send instruction to complying host.
order-url [url!] "TCP or Serial URL"
data "Data to evaluate"
/no-wait "Dont wait for a reply"
sending-port: open order-url
data: mold data
insert sending-port rejoin [
length? data "^/"
rv: now "^/"
if not no-wait [ rv: process-report sending-port ]
;decide how to wait and no-wait on incoming reports
read-reports: func [
process-report: function [
connection: wait [sending-port]
header: copy 
until [ (copy header) = append header load get-line connection ] ; cheezy
header: make object! header
rv: load copy/part connection header/size
either probe header/error [
error: do rv
make error! reform [
*** Could not comply with your order.^/
*** error/type error occured.^/
*** Near: error/near ^/
*** Where: error/where ^/
get-line: function [
Returns a line from a port.
line: copy ""
append line this-char: first conn
#"^/" = this-char
assume-nothing: func [
if argument is unset! returns none, otherwise returns argument.
argument [unset! any-type!]
either value? 'argument [ argument ] [ none ]
The following is an advertisement, and does not necessarily reflect the viewpoint of