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

World: r3wp

[!REBOL3 Schemes] Implementors guide

Andreas
9-Jan-2010
[767]
as a context. with the bind i can make those values appear as if 
they were local words, i.e. buffer refers to event/port/locals/buffer
Graham
9-Jan-2010
[768x2]
... ah ... I missed the client/locals there ...
when the second parameter to a function is more than 10 lines down 
the page ... .it escapes my eye!
Andreas
9-Jan-2010
[770]
yep, it's not that i'd consider it good style anyway ...
Graham
9-Jan-2010
[771x2]
this world is playing busy again :(
http://www.rebol.net/wiki/TCP_Port_Details
Andreas
9-Jan-2010
[773x2]
very low-level, most of it a bit below our concerns :)
but it's good to know that we don't have to take care of partial 
writes
Graham
9-Jan-2010
[775]
read reads a max of 32,000 bytes ... so does this mean if more data 
is coming, another read will be triggered?
Andreas
9-Jan-2010
[776x4]
yes
and i don't think that the 32,000 bytes given in this document are 
realistic
tcp packet size is typically limited to 1500 bytes, so for any significant 
transfer many 'read events will occur
but maybe the "Note: not 32K" comment wants to tell us that the default 
buffer size is 32 :)
Graham
9-Jan-2010
[780x3]
I see that the buffer is shared for both reading and writing
A few issues a couple of years old http://www.rebol.net/wiki/Ports_and_Schemes:_Issues#Issue_4:_WAIT
remove the #
Andreas
9-Jan-2010
[783]
interesting, thanks
Graham
9-Jan-2010
[784x4]
Managed to get a directory listing with my ftp scheme :)
Things are definitely looking up ....
a directory is just a file .. so this means I have file transfer 
"working "
Just looking at what R2 does .. .each time it does a file/directory 
transfer, it opens the data connection, sends the command and then 
closes it again.
Graham
10-Jan-2010
[788x6]
Hmm. I did a LIST and only got 4000 characters back.  I tried it 
again, but delayed the read a bit longer and got the full 8000 characters 
or so.  So, wonder why the data arrriving is not triggering the read 
event
maybe I need to read the number of bytes from the buffer, clear that 
number and try reading again until none
http://rebol.wik.is/Rebol3/Schemes/Ftp
Updated ... I really need a rebol syntax formatter for this
Heh .. the ruby syntax colouriser colors the text strings mainly.
This isn't going to work unless I queue the user commands and process 
them once a command has completed.

It works on my server, but I tried it on one of the linux distro 
sites and there it doesn't.... as my write commands are written to 
the port before the previous commands have completed.
And the state machine becomes very confused ..
Steeve
10-Jan-2010
[794]
Probably, we should think about a framework to build state machine 
oriented processes.
A new dialect ?
eFishAnt
10-Jan-2010
[795x4]
Gregg made a cool FSM dialtect years ago.
dialect
is there a trick to read R3 dns:// ?  I haven't found it.  Didn't 
see any tickets in cure-code.  Should something be submitted there? 
 (last year was 100% R2 product design...I am wanting to port some 
Core stuff to R3, but I need as much network stuff as possible.  
I did write a real-time video codec for R3 a couple years ago...I 
might see if it can hook into the new codec stuff, too.
on-topic as it was also networked...;-)
Graham
10-Jan-2010
[799x3]
There isn't a dns:// scheme written yet.
there is a low level dns lookup occuring in the tcp device ...
fish ... naughty .. you haven't released your video codec for R3
eFishAnt
10-Jan-2010
[802x3]
my bad...was waiting to get real binary numbers so the code shrinks 
to half the size...100% rebol code, too.  Also, I have to figure 
how to hook into the R3 codec infrastructure...and still trying to 
remember my password for R3 chat.
there is a dns://scheme but the usage is either unknown or broken.
print first read dns://www.rebol.com returns none instead of an IP 
tuple
Graham
10-Jan-2010
[805x4]
so this is a r3 video codec?
I find it hard to believe that you wrote this two years ago with 
so little documentation available then!
To get the ip address I suspect all you have to do is do a query 
on a port once the lookup has completed
the dns:// scheme is there .. it's just not finished ...
eFishAnt
10-Jan-2010
[809x3]
It was in the last half of 2007 I wrote it.  R3 was fast enough for 
real-time.
So how do I "query" a port?
my R3 need with DNS is to be able to tell if a domain is there or 
was it mistyped, to prevent calamity
Graham
10-Jan-2010
[812x4]
in the awake handler, there is a 'lookup event
inside this event, use query port
I'm guessing here of course :)
rebol []
make-scheme [
	name: 'dns2
	title: "DNS Protocol"
	spec: make system/standard/port-spec-net [port-id: 80]


	awake: funct [event ] [
		print ["=== Client event:" event/type]
		client: event/port
		switch event/type [
			lookup [
				; print "DNS lookup"
				probe query client
				return true
			]
			connect []
		]
	]
	actor: [
		open: func [
			port [port!]
			/local conn
		] [
			if port/state [return port]
			if none? port/spec/host [http-error "Missing host address"]
			; set the port state
			port/state: context [
				state:
				connection:
				error: none
				awake: none ;:port/awake
				close?: no
			]
			; create the tcp port and set it to port/state/connection
			port/state/connection: conn: make port! [
				scheme: 'tcp
				host: port/spec/host
				port-id: port/spec/port-id
				ref: rejoin [tcp:// host ":" port-id]
			]
			conn/awake: :awake
			open conn
			print "port opened ..."
			; return the newly created and open port
			wait conn
			conn
		]
	]
]

open dns2://www.rebol.com
Pekr
10-Jan-2010
[816]
open? will read work too? Feels weird ...