r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[!REBOL3 Schemes] Implementors guide

Graham
7-Jan-2010
[260x2]
I try this

read daytime://time-a.nist.gov
It says the port gets opened but the awake function is not triggered
Steeve
7-Jan-2010
[262x3]
yes but your actors (open and/or read) must create a tcp port thru 
the host
a scheme is only a wrapper above a tcp connection
(or upd)
Graham
7-Jan-2010
[265]
I know ..
Steeve
7-Jan-2010
[266]
So you have to do a open tcp://host somewhere in your code
Graham
7-Jan-2010
[267]
Oh ... I didn't create the port ...
Steeve
7-Jan-2010
[268]
yes
Graham
7-Jan-2010
[269]
ok, it will have to wait till my tv program finishes now
Steeve
7-Jan-2010
[270x2]
give me some minutes, i will write it
make-scheme [
	name: 'daytime
	title: "Daytime Protocol"
	awake: func [event /local port] [
		print ["=== Client event:" event/type]
		port: event/port
		switch event/type [
			lookup [
				print "DNS lookup"
				open port
			]
			connect [
				print "connected" 
				read port
			]
			read [
				close port
				return true ; quits the awake
			]
		]
		false
	]
	actor: [
		;open: func [port [port!]][port]
		read: func [
			port [port!] /local con
		][
			con: open rejoin [tcp:// port/spec/host ":13"]
			con/awake: :awake
			wait con
			to-string con/data
		]
	]
]

probe read daytime://time-a.nist.gov

=== Client event: lookup
DNS lookup
=== Client event: connect
connected
=== Client event: read
{
55203 10-01-07 07:51:23 00 0 0 282.6 UTC(NIST) *
}
Graham
7-Jan-2010
[272]
thanks
Steeve
7-Jan-2010
[273]
you may add a timeout inside the wait.
Graham
7-Jan-2010
[274x3]
can add it to the spec
I've updated my effort again ... http://rebol.wik.is/Rebol3/Schemes/Daytime
the data is returned deep inside the port object
Steeve
7-Jan-2010
[277x2]
weird !

The open function must not return the tcp port, but the fake daytime 
port.

Because if someone try to thing like this. 
>> port: open daytime://...
then 

>> read port ; ==> the wrong actor is called (not the daytime one).
it may work currently, because you didn"t add other behavior in the 
read actor, but it's just fluke
Gabriele
7-Jan-2010
[279x4]
brian: there is no link to wetan, it is in the r3-alpha file share.
(graham's link above is not complete. there are a few pieces missing, 
and they are missing because the code, even tough it works, is crap 
:)
documentation in the code itself using comments

 - that only works in very simple cases. I did the network detective 
 like that...
Maxim: sorry, I don't understand your point. the code is not available 
to us, so only Carl can write the basic docs...
Graham
7-Jan-2010
[283x4]
Steve ...good point.
Steeve ...
they can do ..

port: open daytime://
wait port 

:)
I've logged onto r3 chat a few times .. seems dead to me.
Pekr
7-Jan-2010
[287x2]
dead? it works, but noone is posting, no?
or you mean dead by activity?
Graham
7-Jan-2010
[289]
dead as in dead quiet
Pekr
7-Jan-2010
[290]
it is dead because all R3 dev. activity is stalled ....
Graham
7-Jan-2010
[291x2]
It is also quite hard to cut and paste as the console doesn't support 
it ..except as a dos console
Have to use the clipboard to transfer stuff to and from the r3 alpha 
console
Pekr
7-Jan-2010
[293]
yes, console under Windows is really bad ... also no multiline support 
for REBOL code ...
Graham
7-Jan-2010
[294]
Is it better under linux?
Pekr
7-Jan-2010
[295]
don't know ...
Carl
7-Jan-2010
[296x3]
Not much.
If you want to suggest a plan for better console, please do.
It would not require much on the reblib side to support a console 
-- most of the code is on the host side.
Pekr
7-Jan-2010
[299]
R2 console code is not reusable?
Carl
7-Jan-2010
[300]
The necessary reblib calls would be for things like word completion, 
since the symbol table is internal to the lib.
Graham
7-Jan-2010
[301]
ditto
Carl
7-Jan-2010
[302]
R2 could be used... but, I had "imagined" there were better packages 
that we could use and get a full featured console.
Graham
7-Jan-2010
[303x2]
well I don't use word completion ... didn't even know it existed 
for files
Le's be practical and reuse R2
Carl
7-Jan-2010
[305]
Is that the most practical?  What ever happened to operating systems 
that provide a real console lib?
Graham
7-Jan-2010
[306]
the most practical is to make it usable for users and optimize later 
on
Carl
7-Jan-2010
[307]
Certainly, we can use our 1998ish console code to start. But, seems 
a bit backward.
Graham
7-Jan-2010
[308x2]
lacking cut and paste as now is somewhat even more backward!
Feels like the original console of 1998 which also lacked cut and 
paste if  I recall correctly