• Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

AltME groups: search

Help · search scripts · search articles · search mailing list

results summary

worldhits
r4wp6
r3wp162
total:168

results window for this page: [start: 1 end: 100]

world-name: r4wp

Group: #Red ... Red language group [web-public]
Bo:
2-Mar-2013
Sometimes, I'm such a dunce!  Something Kaj said in the past hit 
me as I lay awake in bed at 4:45am this morning.  IIRC, he said that 
Red/System could be used to extend R3.  My problem is that I need 
to perform some advanced processing on jpg images.  I wanted to do 
this natively in Red/System, but had issues getting the jpgs loaded 
into bitmap form.  R3 can already load jpgs into bitmap form, so 
why not  call a Red/System compiled executable to do the processing?
Group: Rebol School ... REBOL School [web-public]
NatasjaK:
6-Nov-2012
Sujoy - Kaj is still asleep, I will tell him you asked this question 
as soon as he's awake.
Kaj:
6-Nov-2012
Ah, as Natasja said, not very awake yet here. Sorry
Group: Web ... Anything related to the WWW [web-public]
Chris:
27-Sep-2012
do http://reb4.me/r/oauth

test-site: http://192.168.0.60.xip.io:8080/

probe-lowercase: func [str [string!]][
    lowercase copy str
]

read [
    scheme: 'oauth
    target: 'get
    url: test-site
    user-data: context [a: "Foo"] ; params
    key: make key [
        consumer-key: consumer-secret: "Your Keys Here"
    ]
    user: make user [token: secret: "Your User Keys Here"]
    awake: :probe-lowercase ; result processor, like :load-json
]
Chris:
27-Sep-2012
do http://reb4.me/r/oauth
do http://reb4.me/r/altjson

tm: read [
	scheme: 'oauth
	url: https://api.twitter.com/1/statuses/home_timeline.json
	target: 'get
	user-data: context [count: 10]
	key: make key [
		Consumer-Key: #consumer_key
		Consumer-Secret: #consumer_secret
	]
	user: make user [
		token: #user_key
		secret: #user_secret
	]
	awake: :load-json
]
Group: !REBOL3 ... General discussion about REBOL 3 [web-public]
GrahamC:
13-Jan-2013
http://www.rebol.net/wiki/Ports:_Synchronous_and_Asynchronous_Operations

Is this example supposed to work still?

 port: make port! http://www.rebol.com
   port/awake: func [event] [
       switch event/type [
           connect ready [
               write event/port [get %/]
           ]
           done [
               result: copy event/port
               return true
           ]
       ]
       false
   ]
   open port
   wait port

world-name: r3wp

Group: All ... except covered in other channels [web-public]
Gabriele:
15-Jan-2005
port/awake gets called endlessly
Group: !AltME ... Discussion about AltME [web-public]
Volker:
27-Jan-2006
Ideas are: 

1) timeout could create an error, leaving some resources in wrong 
state. A lot stuff in the input-buffer could trigger an buffer-overrun.

2) processing in /awake (if you use that) could not be correctly 
registered in gc. either gc misses some reference, or finds some 
reference on the return-stack which is not actually a reference. 
because the gc expects a call from a rebol-native and is instead 
called from a normal c-one.
Gabriele:
27-May-2006
on the detective the GC used to crash a lot when invoked while inside 
an awake function. i worked around it by deferring actions. i guess 
this is the same bug or very similar, and it should be fixed in view 
1.3, so a new build of altme should fix it.
Thør:
17-Jun-2006
Thanks Gabriele. Now I'm sure I was half awake when I installed the 
new version. :D
Group: RAMBO ... The REBOL bug and enhancement database [web-public]
sqlab:
21-Jul-2005
I can see where the crash happens.

It happens in or just before an awake function, when the peer closes 
the socket.


On_Data: func [port] [action-time: now con: port msg: copy: copy 
port 
	if any [none? msg empty? msg] [print ... 

and the print is not evaluated.
sqlab:
22-Sep-2005
REBOL [
]       		

On_Data: func [
	port
] [
	msg:  copy port
		
	if any [none? msg  empty? msg] [
		remove find port-list port
		attempt [close port ] 
		return false
	]
	append port/locals/buffer to-string msg
	insert port { }
	false
]

On_Listen: func [
	listen
] [
	conn: first listen
	conn/locals: make object! [
		buffer: make string! 4000
	]
	conn/awake: :On_Data
	sockets: sockets + 1
?? sockets
	append port-list conn  
	false
]


sockets: 0

port-list: reduce [
	listen: open/direct/no-wait/binary tcp://:13011 
]
listen/awake: :On_Listen


forever [
	error?  try [
		conn: wait port-list
	] 
] 
close listen
Anton:
20-Nov-2006
Just to be sure... when running the second server, I should expect 
a print out of "false-awake-event" to indicate the bug, shouldn't 
I ?
sqlab:
1-Dec-2006
I have a slightly modified help, that does not evaluate functions 
in objects and ports and that also dumps ports like objects.
>> a: open http://www.rebol.com
connecting to: www.rebol.com
>> help a
A is a port of value:
   scheme          word!     HTTP
   host            string!   "www.rebol.com"
   port-id         integer!  80
   user            none!     none
   pass            none!     none
   target          none!     none
   path            none!     none
   proxy           object!   [host port-id user pass type bypass]
   access          none!     none
   allow           none!     none
   buffer-size     none!     none
   limit           none!     none

   handler         object!   [port-flags open-check close-check write-check 
   ini...
   status          word!     file
   size            integer!  0
   date            date!     6-Nov-2006/21:26:44
   url             string!   "http://www.rebol.com/"

   sub-port        port!     make port! [ scheme: 'tcp host: "www.rebol.com" 
   po...
   locals          object!   [list headers querying]

   state           object!   [flags misc tail num with custom index 
   func fpos i...
   timeout         integer!  30
   local-ip        none!     none
   local-service   none!     none
   remote-service  none!     none
   last-remote-service none! none
   direction       none!     none
   key             none!     none
   strength        none!     none
   algorithm       none!     none
   block-chaining  none!     none
   init-vector     none!     none
   padding         none!     none
   async-modes     none!     none
   remote-ip       none!     none
   local-port      none!     none
   remote-port     none!     none
   backlog         none!     none
   device          none!     none
   speed           none!     none
   data-bits       none!     none
   parity          none!     none
   stop-bits       none!     none
   rts-cts         logic!    true
   user-data       none!     none
   awake           none!     none

Is there interest in including in the new release?
Group: Core ... Discuss core issues [web-public]
Micha:
16-Mar-2005
;serwer proxy


p: make port! tcp://:80

p/awake: func [ port /local  data conn targed cmd partner url 
] [



conn: first port
wait conn
data: to-string copy conn

replace/all data "^M" ""
source data

targed: copy/part data find data "HTTP/1.1"
data: find/tail data "^/"
print targed

cmd: parse targed none

url:  decode-url cmd/2 

if not url/path  [url/path: "" ]

if not url/target  [url/target: ""]

partner: open/no-wait to-url rejoin [ "tcp://" url/host ":80" ]




insert partner rejoin [ cmd/1" /" url/path url/target " HTTP/1.1^/" 
 data]

wait partner

tmp: copy partner




close partner



insert conn tmp



close conn 

]


append system/ports/wait-list p


open/binary/no-wait p
 wait []


halt
Volker:
16-Mar-2005
conn: first port
wait conn ; such things in /awake may be a problem.
Volker:
16-Mar-2005
i would not use /awake in your case. more like
  forever[ wait port  your-code-here ]
sqlab:
17-Mar-2005
Micha:
regarding your Async Server

You can modify your awake function like this

p/awake: func [ port /local  data  ] [
 	data: copy port
	either data [
		append tmp data
	] [
		close p 
		remove find system/ports/wait-list p
	]
]
Micha:
28-Apr-2005
how do to write this using harbour / awake ?
without using from  port / async ?
Micha:
28-Apr-2005
handler: func [port ] [ 
                                    
       

          ping: to-integer  (0:00:30 - get-modes port 'timeout )* 1000
                                     

                    print [ "open" port/remote-ip  port/remote-port  "ping:" ping ]

                   insert port join  #{0401} [debase/base  skip to-hex 80 4 16 to-binary 
                   193.238.73.117 #{00} ]
           
    ]


port: make port! tcp://219.147.198.195:1080 

set-modes port [timeout: 00:01:00]

port/awake: :handler

insert tail system/ports/wait-list  port



open/binary port
Micha:
30-Apr-2005
rebol []

conn: make port! tcp://:80



black-lista: [ 69.64.51.223 194.69.207.145 80.252.0.145 194.69.207.165 
217.73.17.115]




adns: open/no-wait make port! dns:///async

adns/awake: func [port /local dat][                
		
		data: copy port

                print data
		
		false 
	]				

insert tail system/ports/wait-list adns





heandler: func [ port /local data dns  ]

               [ print "new connetion"

               serwer: first port

               client: make port! tcp://222.76.73.113:1080
              
               
               serwer/sub-port: client
               client/sub-port: serwer

               set-modes client [no-wait: true timeout: 00:01:00]
               set-modes serwer [no-wait: true ]

                          
 wait serwer
             
data: copy serwer



dns: to-tuple copy/part skip to-binary  data 4 4  

insert adns dns ;print dns name



either find black-lista dns [ close serwer  print "firtled" print 
read join dns:// dns ]
                           

                            [ insert serwer  join #{005A} [debase/base  skip to-hex serwer/port-id 
                            4 16 to-binary dns ] 



insert tail system/ports/timeout-list client

      open/binary client 

ping: to-integer  (0:01:00 - get-modes client 'timeout )* 1000 

  print [ "open" ping ]
                                                


                              insert client data

                              wait client

data: copy client



client/awake: :response

serwer/awake: :request

insert tail system/ports/wait-list  client


insert tail system/ports/wait-list  serwer







] 



       false         
]




request: func [ port /local data   ] 

              [ data: make string! 10000
               read-io port data 10000

                either data <> {} [ 
                                    insert port/sub-port data ] 

                            [  close port 

                              remove find system/ports/wait-list port port
                              print "close connetion serwer"

                              print length? system/ports/wait-list
                               ]

                 halt]




       
   


  
response: func [ port /local data   ] 

               [ data: make string! 10000
               read-io port data 10000

 
               either data <> {} [ 
                             insert port/sub-port data  ]

                            [  close port 

                              remove find system/ports/wait-list port port
                              print "close connetion client"

                              print length? system/ports/wait-list
                             ]

                 halt]




conn/awake: :heandler

set-modes conn [no-wait: false]

insert tail system/ports/wait-list  conn

open/direct/binary conn


print "proxy"

halt
Micha:
4-May-2005
whois: func [ host /local port ][  port: make port! join tcp:// [192.149.252.44 
":43" ]


                                   port/awake: func [ port /local  ][data: copy port 


                                                      either data [  show data ]

                                                                              

                                                                 [ close port 

                                                                   remove find system/ports/wait-list port ]
                                                    
                                                      halt]



                                 insert tail system/ports/wait-list port

                                 open/no-wait port
                 

                                 insert port join "+" [ host "^/"] ]


                                   
show: func [ d /local alpha ][ 


alpha: charset [#"A" - #"Z" #"a" - #"z"]

d: find/tail  d "City:"
a: copy d
a: find/tail a alpha
a: copy/part a find a "^/"

print [ "City: " a ] 


b: find/tail d "StateProv:"
d: copy b
b: find/tail b alpha
b: copy/part b find b "^/"

print [ "StateProv: " b ]


c: find/tail  d "Country:"
c: find/tail c alpha
c: copy/part c find c "^/"

print [ "Country: " c ]   ]











whois 24.3.46.214
Micha:
7-May-2005
REBOL [Title: "proxy multiple" ] 

print "start-multiple"
 list: []

proxy: make object! [ host: 24.186.191.254
                      port-id: 29992 ]

ph: func [port][ switch port/locals/events [
                          
                          connect [insert tail list  port

                                   ping: to-integer (now/time - port/date ) * 1000 
                                   port/date: now/time

                                   print [ "open   ping: " ping ]  ]

                          close [ remove find list port
                                  init

                                  ping: (now/time - port/date ) * 1000 

                                   print ["close   ping: " ping ] close port ]

                                                ]


false ]



stop: func [] [ clear system/ports/wait-list
               forall list [close first list ]]

init: func [ /local port ][ port: make port! [ scheme: 'atcp
                                               host: proxy/host

                                               port-id: proxy/port-id
                                               awake: :ph 
                                               date: now/time ]

                            open/no-wait/binary  port


                            insert tail system/ports/wait-list  port ]



set: func [ h p ] [ proxy/host: h
                    proxy/port-id: p ]
                          

send: func [ port ][ port/date: now/time

insert port join  #{0401} [debase/base  skip to-hex 80 4 16 to-binary 
193.238.73.117 #{00}] ]
Micha:
7-May-2005
>> init
** User Error: No network server for atcp is specified
** Near: port: make port! [scheme: 'atcp
    host: proxy/host
    port-id: proxy/port-id
    awake: :ph
    date: now/time]
open/no-wait/binary
>>
Micha:
5-Jun-2005
rebol [ title: "SOCKS SERWER" ]

conn: make port! tcp://:800

proxy: make object! [ host: 208.59.117.69
                      port: 2988  ]



black-lista: [ 69.64.51.223 194.69.207.145 80.252.0.145 194.69.207.165 
217.73.17.115]




adns: open/no-wait make port! dns:///async

adns/awake: func [port /local data][                
		
		data: copy port

                print data
		
		false 
	]				

insert tail system/ports/wait-list adns





heandler: func [ port /local data dns  serwer client]

               [ serwer: first port

                          
 wait serwer
             
data: copy serwer
;data: make string! 10000
;read-io serwer data 10000
print ["data1" to-binary data]

dns: to-tuple copy/part skip to-binary  data 4 4  

insert adns dns ;print dns name



either find black-lista dns [ close serwer  print "firtled" print 
read join dns:// dns ]
                           
                            [ print "new connetion"

insert serwer  join #{005A} [debase/base  skip to-hex serwer/port-id 
4 16 to-binary dns ] 


client: make port! [ scheme: 'tcp 
                     host: system/words/proxy/host
                     port-id: system/words/proxy/port
]



;insert tail system/ports/timeout-list client

      open/no-wait/binary/async/direct client :response


client/sub-port: serwer





insert tail system/ports/wait-list  client

client/date: data

serwer/sub-port: client

serwer/awake: :request









] 



       false         
]




request: func [ port /local data  f ] 

              [ data: make string! 10000
               read-io port data 10000


if f: find data "GET /favicon.ico" [ insert port "HTTP/1.1 404 Not 
Found" 
                                      print "favicon.ico"]
 


                either (data <> {}) and not f [     print [ "data3" data  ]
                              

                                if error? try [    write-io port/sub-port data length? data ][ print 
                                "error: close serwer"]
                                   ; insert port/sub-port data 
]

                            [  close port 

                              remove find system/ports/wait-list port port
                               close port/sub-port

                              remove find system/ports/wait-list port/sub-port port/sub-port
                              print "close connetion client"

                               print length? system/ports/wait-list
                               ]

               false]




       
   


  
response: func [ port e a /local data  f  ] 

               [  switch e [ open [ insert port port/date ]
                                    
                             read [ data: copy/part port a

                                   either ( a <> 8 ) [write-io port/sub-port data length? data] 

                                                     [  insert tail system/ports/wait-list  port/sub-port ]
                                    ]
                                     
                             close [ close port 

                                     remove find system/ports/wait-list port port
                                     close port/sub-port

                                     remove find system/ports/wait-list port/sub-port port/sub-port

                                       print "close connetion serwer"

                                      print length? system/ports/wait-list]
 

                          ]   ]


start: func [] [

conn: make port! tcp://:800

conn/awake: :heandler

set-modes conn [no-wait: false]

insert tail system/ports/wait-list  conn

open/no-wait/direct/binary conn ]


stop: func [][ close conn
               remove find system/ports/wait-list conn]

set-proxy: func [ h p ] [ proxy/host: h
                          proxy/port: p ]
                          


print "proxy"

lay:  layout [ backdrop blue
              across  h3  red "PROXY" f: field 145 
              return
              button green "start" [ p: parse f/text  ":"
                                     remove find p "" 

                                     set-proxy  to-tuple p/1  to-integer p/2
                                     source p
                                    
                                     start]
              button  green "stop" [f/text: "" stop ] ]

view/offset lay 4x29 
halt
MichaelAppelmans:
11-Jun-2005
wow, I'm impressed, I might have to stay awake for this ;)!!
sqlab:
15-Mar-2006
I just tested it with awake functions and this gave me data from 
two ports alternately.  Thanks god, that I use this approach since 
I heard about it. Probably the efficiency and the time granularity 
there is higher.
Cyphre:
28-Nov-2006
system-awake: func [port /local msg][
	msg: pick port 1
	print [
		switch msg/2 reduce [
			WM_KEYDOWN ["key down"]
			WM_KEYUP ["key up"]
		]
		"keycode:" msg/3
		"char:" mold to-char msg/3
	]
	return false
]

WM_KEYDOWN: 256
WM_KEYUP: 257

system/ports/system: open [scheme: 'system]
system/ports/system/awake: :system-awake

set-modes system/ports/system compose/deep [winmsg: [(WM_KEYDOWN) 
(WM_KEYUP)]]
append system/ports/wait-list system/ports/system

wait []
Joe:
12-Jan-2007
f-awake: func [
	port
	/local res
][
	res: 	copy port
	print 	[port/user-data/host res]
	remove	find system/ports/wait-list port
	false
]


b-hosts: [ "www.rebol.net" "www.google.com" "www.yahoo.com" "www.microsoft.com" 
"xxafda" "www.ebay.com" "www.amazon.com" ]
foreach	h b-hosts [
		 p: 	open/no-wait make port! [
				scheme: 	'dns
				host:		"/async"
				user-data:	reduce ['host h]
				awake:		:f-awake
			]
		insert	tail system/ports/wait-list p
		insert	p h
	]
wait 	[]
[unknown: 5]:
16-Jun-2008
Would be nice to have the feature to access the currently indexed 
position of the open port and perform a function on it.  For example, 
modify /awake to work with files.  Such that any reference to the 
file or altering of the position can be handle via an awake/handler.
Dockimbel:
1-Feb-2009
I've just hit a serious issue in 2.7.6 on UNIX platforms today.


Briefly: CLOSE on TCP ports doesn't work anymore if CALL is used 
before CLOSE, in a AWAKE handler.

To reproduce this bug, get the tests scripts here :

write %server.r read http://softinnov.org/tmp/server.r
write %client.r read http://softinnov.org/tmp/client.r
write %foo.r read http://softinnov.org/tmp/foo.r


Then, read the comment section in %server.r and launch it to see 
by yourself : do %server.r

Notes:
     o Windows is not affected by this issue.

     o I consider this a major issue for all REBOL server applications 
     working in async mode and spawning processes.

     o I'm posting first here before RAMBO, so that people can test and 
     point out any possible bad interpretation from me.
Anton:
2-Feb-2009
After 5 seconds, client.r and foo.r are present:

$ ps aux | grep reb[v]iew

anton     9006  0.0  0.4  13268  9656 pts/1    SNs+ 00:33   0:00 
/rebol/rebview2.7.006.4.2 -s -- do-anton-user?: true

anton     9007  0.0  0.0   6084   536 pts/1    SN+  00:33   0:00 
/rebol/rebview2.7.006.4.2 -s -- do-anton-user?: true

anton     9008  0.0  0.0   6084   464 pts/1    SN+  00:33   0:00 
/rebol/rebview2.7.006.4.2 -s -- do-anton-user?: true

anton     9072  0.3  0.3  11952  8228 pts/1    SN+  00:35   0:00 
/rebol/rebview2.7.006.4.2 -qws client.r

anton     9073  0.0  0.0   6128  1084 pts/1    SN+  00:35   0:00 
/rebol/rebview2.7.006.4.2 -qws client.r

anton     9074  0.0  0.0   6084   468 pts/1    SN+  00:35   0:00 
/rebol/rebview2.7.006.4.2 -qws client.r

anton     9079  0.5  0.3  11828  8068 pts/1    SN+  00:35   0:00 
/rebol/rebview2.7.006.4.2 -qws foo.r

anton     9080  0.0  0.0   6084   536 pts/1    SN+  00:35   0:00 
/rebol/rebview2.7.006.4.2 -qws foo.r

anton     9081  0.0  0.0   6084   464 pts/1    SN+  00:35   0:00 
/rebol/rebview2.7.006.4.2 -qws foo.r

After foo.r finishes waiting:

$ ps aux | grep reb[v]iew

anton     9006  0.0  0.4  13268  9656 pts/1    SNs+ 00:33   0:00 
/rebol/rebview2.7.006.4.2 -s -- do-anton-user?: true

anton     9007  0.0  0.0   6084   536 pts/1    SN+  00:33   0:00 
/rebol/rebview2.7.006.4.2 -s -- do-anton-user?: true

anton     9008  0.0  0.0   6084   464 pts/1    SN+  00:33   0:00 
/rebol/rebview2.7.006.4.2 -s -- do-anton-user?: true

anton     9072  0.4  0.0      0     0 pts/1    ZN+  00:35   0:00 
[rebview2.7.006.] <defunct>

anton     9079  0.4  0.0      0     0 pts/1    ZN+  00:35   0:00 
[rebview2.7.006.] <defunct>


And when close port is done before call in the awake function, then 
client.r becomes defunct while foo is still waiting.
Graham:
9-Jun-2010
I've been playing a little with Gabriele's async http, and I note 
that the subport only sends back close and error events to the main 
awake handler.
Gabriele:
10-Jun-2010
Graham: on close you can just close the port (so that it is removed 
from the wait list). apparently not doing that causes an error (not 
sure if this is new, or i just never catched it before; anyway i 
think rebol should not be calling the awake after the port has been 
closed)
Graham:
12-Jun-2010
Gab's async protocol, the awake event takes two parameters
Romano's atcp protocol, the awake event takes one parameter ....
Group: View ... discuss view related issues [web-public]
Anton:
28-Feb-2005
This I grabbed in Dec 2002
Rebol [
	title: "little custom tray exapmle"
	author: [cyphre-:-seznam-:-cz]
]

set-tray: does [
set-modes system/ports/system [
	tray: [
		add main [
			help: "Just some help line"
			menu: [
				desktop: "This is my tray"
				bar
				test: "test item"
				bar
				quit: "Quit"
			]
		]
	]
]
]
system-awake: func [port /local r][
    if all [r: pick port 1 (r/1 = 'tray)] [

        if any [(r/3 = 'activate) all [(r/3 = 'menu) (r/4 = 'desktop)]][

  view/new/offset layout [banner "you clicked the tray button 1"] random 
  200x200
        ] 

        if all [(r/3 = 'menu) (r/4 = 'test)] [view/new/offset layout [banner 
        "you clicked the tray button 2"] random 200x200]
        if all [(r/3 = 'menu) (r/4 = 'quit)] [quit]
    ]
    return false
]
system/ports/system: open [scheme: 'system]
append system/ports/wait-list system/ports/system
system/ports/system/awake: :system-awake 
set-tray
wait []
Volker:
26-Mar-2005
but do you really need the wait? or could you give the thing you 
wait for a fresh /awake, and return?
Volker:
25-Jan-2006
do/args http://polly.rebol.it/test/test/scratch/simcon.r[
probe event-port
# length? system/ports/wait-list
# same? first system/ports/wait-list system/view/event-port
# get in system/view/event-port 'awake
# probe we: get in system/view 'wake-event
# insert second :we [prin "*"] 
# view layout[area] none
]
Janeks:
25-Jan-2006
It works for me! Thanks!
Is it correct?

I looked into system/ports/wait-list - there is a lot variables and 
awake function.
For what else wait-list is good?
Volker:
25-Jan-2006
i guess a search for "awake rebol" would turn something up.
Volker:
18-Jun-2006
probe first system/view 
probe get in system/view/event-port 'awake 
make system/view [source wake-event] 
system/view/wake-event: func [port /local event no-btn] bind [
    event: pick port 1 
print remold [event/type event/offset event/key] 
    if none? event [

        if debug [print "Event port awoke, but no event was present."] 
        return false
    ] 
    either pop-face [

        if in pop-face/feel 'pop-detect [event: pop-face/feel/pop-detect 
        pop 
            -face event
        ] 
        do event 
        found? all [
            pop-face <> pick pop-list length? pop-list 
            (pop-face: pick pop-list length? pop-list true)
        ]
    ] [
        do event 
        empty? screen-face/pane
    ]
] system/view 
echo on 
print "con" 
view layout [button "test" [probe "test"]]
Volker:
18-Jun-2006
This is called from system/view/event-port/awake. when it returns 
false, the do-events should terminate.
Gabriele:
19-Jun-2006
do you have any ports in the wait-list, with an awake function that 
is not returning false? note that if you return none it does not 
work, only with false wait will continue waiting.
Robert:
19-Jun-2006
I add the probe do-events and here is the result:
probe do-events

make port! [
    scheme: 'event
    host: none
    port-id: none
    user: none
    pass: none
    target: "events"
    path: none
    proxy: none
    access: none
    allow: none
    buffer-size: none
    limit: none
    handler: none
    status: none
    size: none
    date: none
    url: none
    sub-port: none
    locals: none
    state: make object! [
        flags: 4719107
        misc: none
        tail: 0
        num: 1
        with: "^/"
        custom: none
        index: 0
        func: 12
        fpos: 0
        inBuffer: none
        outBuffer: none
    ]
    timeout: none
    local-ip: none
    local-service: none
    remote-service: none
    last-remote-service: none
    direction: none
    key: none
    strength: none
    algorithm: none
    block-chaining: none
    init-vector: none
    padding: none
    async-modes: none
    remote-ip: none
    local-port: none
    remote-port: none
    backlog: none
    device: none
    speed: none
    data-bits: none
    parity: none
    stop-bits: none
    rts-cts: true
    user-data: none
    awake: func [port][wake-event port]
]
Anton:
9-Oct-2006
Starting at the top:
system/view/event-port/awake --->  system/view/wake-event
Gregg:
4-May-2009
REBOL []

; r/3 = 'activate = left-click
; r/3 = 'activate = rt-click+menu-item-sel

hex: func [
    {Returns the base-10 value of a hexadecimal number.}
    value [integer! string! issue!] "A hexadecimal number"
][

    ; Convert to an issue first, so integers can also be translated.
    to integer! to issue! value
]

make-elements: func [name count type /local result][
    if not word? type [type: type?/word type]
    result: copy "^/"
    repeat i count [
        append result join name [i " [" type "]" newline]
    ]
    to block! result
]

NOTIFYICONDATA: make struct! compose [
    cbSize  [integer!]
    hwnd    [integer!]
    uId     [integer!]
    uFlags  [integer!]
    uCallBackMessage [integer!]
    hIcon   [integer!]
    (make-elements 'szTip 64 #"@")  ; CHAR
] none
NOTIFYICONDATA/cbSize: length? third NOTIFYICONDATA

;change at third NOTIFYICONDATA 25 "New ToolTip!"
;probe NOTIFYICONDATA
;halt

;constants required by Shell_NotifyIcon API call:
NIM_ADD:     hex 0
NIM_MODIFY:  hex 1
NIM_DELETE:  hex 2
NIF_MESSAGE: hex 1
NIF_ICON:    hex 2
NIF_TIP:     hex 4
WM_MOUSEMOVE:       hex 200
WM_LBUTTONDOWN:     hex 201  ;   'Button down
WM_LBUTTONUP:       hex 202  ;     'Button up
WM_LBUTTONDBLCLK:   hex 203  ; 'Double-click
WM_RBUTTONDOWN:     hex 204  ;   'Button down
WM_RBUTTONUP:       hex 205  ;     'Button up
WM_RBUTTONDBLCLK:   hex 206  ; 'Double-click


;Public Declare Function SetForegroundWindow Lib "user32" (ByVal 
hwnd As Long) As Long

lib: load/library %shell32.dll

Shell_NotifyIcon: make routine! compose/deep [
    dwMessage [integer!]
    pnid      [struct! [(NOTIFYICONDATA)]]
    return:   [integer!]
] lib "Shell_NotifyIconA"


my-hwnd?: does [second get-modes system/ports/system [window]]

set-tray-tooltip: func [struct string] [
    change at third struct 25 string
    struct
]



system-awake: func [port /local evt][
    if all [evt: pick port 1  (evt/1 = 'tray)] [
        status/text: mold evt
        show status
;         if any [
;             (evt/3 = 'activate)
;             all [(evt/3 = 'menu)  (evt/4 = 'desktop)]
;         ] [
;             if not desktop-loaded [
;                 link-exec-start-desktop/force
;             ]
;         ]
;         if all [(evt/3 = 'menu)  (evt/4 = 'quit)] [quit]
    ]
    false
]

system/ports/system/awake: :system-awake
append system/ports/wait-list system/ports/system

view layout [
    style button button 200
    button "Add Tray Menus" [
        set-modes system/ports/system compose/deep [
            tray: [
                add main [

                    help: (rejoin ["REBOL/Link" any [""]]) ; tooltip

                    menu: [test: "Test" desktop: "Start Desktop" bar quit: "Quit"]
                ]
                add other [
                    ;help: (rejoin ["REBOL/Link" any [""]])
                    menu: [test-2: "Test-2" bar quit-2: "Quit-2"]
                ]
            ]
        ]
    ]
    button "Remove Tray Main Menu" [
        set-modes system/ports/system [
            tray: [remove main]
        ]
    ]
    button "Remove Tray Other Menu" [
        set-modes system/ports/system [
            tray: [remove other]
        ]
    ]
    ;button "Change Tray Other Menu" [
    ;    set-modes system/ports/system [
    ;        tray: [
    ;            change other [
    ;                help: "New Help!"

    ;                menu: [test-3: "Test-3" bar quit-3: "Quit-3"]
    ;            ]
    ;        ]
    ;    ]
    ;]
    button "Modify Tooltip" [
        nid: make struct! NOTIFYICONDATA none
        nid/hwnd: my-hwnd?
        nid/uid: 1
        nid/cbSize: length? third nid
        nid/uFlags:  NIF_TIP  ; NIF_ICON
        ;nid/hIcon:
        ;nid/szTip:  "New ToolTip!^@"
        set-tray-tooltip nid "New ToolTip A!"
        ;print mold third nid
        res: Shell_NotifyIcon NIM_MODIFY nid
        print [res to logic! res]
    ]
    button "Modify Other Tooltip" [
        nid: make struct! NOTIFYICONDATA none
        nid/hwnd: my-hwnd?
        nid/uid: 2
        nid/cbSize: length? third nid
        nid/uFlags:  NIF_TIP  ; NIF_ICON
        ;nid/hIcon:
        ;nid/szTip:  "New ToolTip!^@"
        set-tray-tooltip nid "New ToolTip B!"
        ;print mold third nid
        res: Shell_NotifyIcon NIM_MODIFY nid
        print [res to logic! res]
    ]
    button "Unview" [unview]
    status: text 200
]



free lib
Gabriele:
4-Nov-2009
the awake handler needs to return TRUE
Nicolas:
31-Mar-2010
system/schemes/system: make object! [
    name: 'system
    title: "System Port"
    spec: none
    info: none
    actor: make native! [[port!]]
    awake: make function! [[
        sport "System port (State block holds events)"
        ports "Port list (Copy of block passed to WAIT)"
        /local event port waked
    ][
        waked: sport/data
        loop 8 [
            if not event: take sport/state [break]
            port: event/port
            if wake-up port event [
                if not find waked port [append waked port]
            ]
        ]
        if not block? ports [return none]
        forall ports [
            if find waked first ports [return true]
        ]
        false
    ]]
    init: make function! [[port][
        port/data: copy []
    ]]
]
Group: Parse ... Discussion of PARSE dialect [web-public]
Tomc:
3-Aug-2005
arrg not awake ... recursion limit
Group: Linux ... [web-public] group for linux REBOL users
Anton:
15-Aug-2009
console-port: open/binary/no-wait console:/
console-port/awake: func [port /local ch][
	if ch: pick port 1 [
		;print ["Console awake trapped key:" to-char ch "(" ch ")"]
		either ch = #"^V" [	; Ctrl+V

   call "xclip -o -selection clipboard" ; Three different types of clipboards: 
   "primary", "secondary" or "clipboard".
		][
			insert system/ports/output to-char ch
		]
	]
	return false ; Does not cause return from WAIT (DO-EVENTS).
	;true ; Does cause return from WAIT (DO-EVENTS).
]

insert system/ports/wait-list console-port
if error? set/any 'err try [
	do-events
][
	print mold disarm err
]
close console-port
remove find system/ports/wait-list console-port
Anton:
15-Aug-2009
I've tried replacing system/ports/input/awake with an awake function 
similar to above, and it doesn't seem ever to be called. If it's 
possible at all I think making a handler object with all the functions 
(open close write etc.) *might* work.
Gabriele:
17-Aug-2009
awake is only called if you use WAIT (which the native console does 
not use - indeed you don't get other port events while at the console 
prompt)
Anton:
22-Aug-2009
Would your above system need WAIT ?

The only way I got console port to work is to set its awake function 
and use WAIT.
Group: AGG ... to discus new Rebol/View with AGG [web-public]
Gabriele:
4-Jun-2007
or even have a single event function as event awake (you can do this 
in R2 too)
Group: Announce ... Announcements only - use Ann-reply to chat [web-public]
Alan:
11-Feb-2006
Gabriele: got this when i tried clips.r    Script Error: Invalid 
path value: awake
** Near: system/ports/system/awake: func [port /local msg] [
    while [msg: pick port 1] [
        if find/match msg [tray main ...
Group: !RebGUI ... A lightweight alternative to VID [web-public]
Graham:
13-Jul-2006
maybe some wizard will have fixed it by the time I awake :)
Group: rebcode ... Rebcode discussion [web-public]
BrianH:
12-Oct-2005
These are questions for later answer, when sensible Americans are 
awake :)
Group: Tech News ... Interesting technology [web-public]
Pekr:
9-Feb-2007
Apple's iPhone has got a competition. It it in no way revolutionary. 
Eugenia from OSNews has some nice blog about it. First there was 
LG, now there is Samsung - those companies surely had such products 
in development for quite some time. Here's first look at Samsungs 
machine. And it got keyboard!


http://www.akihabaranews.com/en/en/news-13261-When+the+Korean+GOD+awake%2C+he+gives+us...+the+Samsung+Ultra+Smart+F700.html
Group: !REBOL3-OLD1 ... [web-public]
Gabriele:
22-May-2007
>> p: make port! http://www.rebol.com
>> type? p/handler
== object!
>> type? p/awake
== none!
Micha:
10-Jan-2008
there is the better solution ?

handl: func [event /local port] [  probe  event/type


port: event/port

switch event/type [

connect [  print  [ now port/spec/host  ]
           write port [ GET %/index.html ]  false]

read [ false ]


wrote [ false]


done [   print  [ port/spec/host  length? event/port/data ]  true]

close [ close port true]
error [ close port true]


] 

]




get-fast: func [hosts /local port ][



 foreach hst hosts [
  port: make port!  to-url join http:// hst 

  port/awake: :handl
  open port

wait 0.03
 ]


]

;example

urls: [
www.rebol.com
www.rebol.net
;"www.rebol.org"
www.apple.com
;"www.oracle.com"
;"www.google.com"

]
loop 10 [get-fast urls]
Steeve:
28-Apr-2009
This is the very minimalist event handler i use to do my tests on 
gobs and events.
then, just add your gobs into the main screen gob

set 'screen system/view/screen-gob
unless system/view/event-port [
	system/view/event-port: open [scheme: 'event]
]
system/view/event-port/awake: func [event /local gob offset ev][
	ev: map-event event
	gob: ev/gob 
	offset: ev/offset 
	switch event/type [
		move [...]
		up [...]
		down [...]
		...
	]
	tail? screen
]

append screen make gob! [...]
do-events
Nicolas:
16-Aug-2009
make port! [
    spec: make object! [
        title: "DNS Lookup"
        scheme: 'dns
        ref: dns://www.rebol.net
        path: none
        host: "www.rebol.net"
        port-id: 80
    ]
    scheme: make object! [
        name: 'dns
        title: "DNS Lookup"
        spec: make object! [
            title: none
            scheme: none
            ref: none
            path: none
            host: none
            port-id: 80
        ]
        info: none
        actor: make native! [[]]
        awake: make function! [[event][print event/type true]]
    ]
    actor: make native! [[]]
    awake: make function! [[event][print event/type true]]
    state: #{}
    data: none
    locals: none
]
Claude:
29-Oct-2009
wp: make port! tcp://user:[pass-:-telnetserver]:23
wp/awake: func [event /local port] [
    port: event/port
    print ["==TCP-event:" event/type]
    switch/default event/type [
        read [print ["read:" length? port/data] read port]
        wrote [read port]
        lookup [print query port open port]
        connect [write port {ls -lisa}]
    ][true]
]
open wp
wait [wp 5]
print wp/data
close wp
Group: Plugin-2 ... Browser Plugins [web-public]
Volker:
10-May-2006
ANd when i am awake again, i check out these plugins .)
Group: !Cheyenne ... Discussions about the Cheyenne Web Server [web-public]
Dockimbel:
31-Dec-2008
Ok, try this : paste the following code in a fresh console (2.7.6) 
and try to reproduce the error :

s: open/binary/direct/no-wait tcp://:8003
append system/ports/wait-list s
s/async-modes: 'accept
s/awake: func [server-port /local err new][
	either error? err: try [
		new: first server-port 
	][
		err: disarm err
		if err/code <> 517 [?? err]
		false
	][
		insert tail system/ports/wait-list new
		new/async-modes: [read]
		new/awake: func [port][
			print "event received"
			probe copy port
			false
		]
		set-modes new [no-delay: on]
		false
	]
]
set-modes s [no-delay: on]
wait [ ]
Dockimbel:
15-May-2009
IIRC, when writing on an async port in R2, you're supposed to set 
the 'write mode in port/async-modes. That will make REBOL keep calling 
port/awake function until all the data has been sent.
Maxim:
15-May-2009
no, what is happening is that task-handlers hang (for known and uniserve-independent 
reasons) so I can't rely on the normal uniserve system.


I must catch further connections as soon as possible, since they 
have to report errors without triggering the installed mods.  going 
through the different levels of apis, really complicates this handling, 
which now, basically is all done within the on-accept awake func 
of uniserve.


based on your note about the async I/O above, I think I'll add an 
extension to on-data to handle the specific case where that specific 
connection was refused, waiting for the error report to finish and 
I'm all set.
Dockimbel:
15-May-2009
To make a more complete answer to your data sending question : I'm 
don't remember precisely, but I think that  REBOL signals that all 
the outgoing data has been processed by calling again port/awake. 
It's then, up to the programmer, to decide if :
    - there's more data to send

    - no more data to send, so get back to a read-only state (this implies 
    unsetting the 'write mode in port/async-modes)
    - the port needs to be closed.
Dockimbel:
15-May-2009
That means that the outgoing buffer is not yet empty and that the 
write-io would block in that case (but that case is not allowed in 
async mode, so an error (code 517) is raised, allowing you to escaped 
and wait the next call to awake to retry a new write operation.
Maxim:
15-May-2009
ok so basically you can be awaken while writing is still going on 
within the previous awake call... but the first one is still blocked, 
until that first write-io is done.

have I got it right?
Maxim:
15-May-2009
(the first awake call, that is)
Maxim:
15-May-2009
does the tcp stack awake us when it has finished?
Dockimbel:
15-May-2009
Yes, ugly, but that's AFAIK the only way to know when the data has 
been really sent. Btw, IIRC, REBOL is already doing busy looping 
in async mode to fire the awake event for 'write async mode.
Group: DevCon2007 ... DevCon 2007 [web-public]
Ashley:
9-May-2007
Loved this line from the unofficial description;  "... main aim is 
to keep everyone awake." ;)
Anton:
10-May-2007
Hmm.. can I stay awake for a couple more hours...
BrianH:
11-May-2007
I hope that they get the slides or static copies of the streams up 
soon. With my schedule, I have not been able to be awake and online 
during any of the presentations, even to chat here.
Group: !REBOL3 Schemes ... Implementors guide [web-public]
Graham:
5-Jan-2010
read and write are very similar ... can we do this?

		read: func [
			port [port!]
			/write data
		] [
			either any-function? :port/awake [

    unless open? port [cause-error 'Access 'not-open port/spec/ref] 
				if port/state/state <> 'ready [http-error "Port not ready"] 
				port/state/awake: :port/awake 
				do-request port 
				port
			] [
				sync-op port either write [ data ] [[]]
			]
		] 
		write: func [
			port [port!] 
			value
		] [

   unless any [block? :value any-string? :value] [value: form :value] 

   unless block? value [value: reduce [[Content-Type: "application/x-www-form-urlencoded; 
   charset=utf-8"] value]] 
			read/write port data 
		]
Graham:
7-Jan-2010
It says the port gets opened but the awake function is not triggered
Steeve:
7-Jan-2010
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
At present you have to supply an awake handler to the port ...
Graham:
8-Jan-2010
I've been reading some more of the docs .. and it says that the lookup 
phase in the awake handler is called when the name is resolved with 
a dns lookup .. but that phase is not used when the url uses an ip 
address.  But then I see some demo code using IP addresses ( the 
ping pong server ) where the open port is in the lookup event ...
Graham:
8-Jan-2010
this is the ping client

client: open tcp://127.0.0.1:8080

client/awake: func [event] [
    ;probe event/type
    switch event/type [
        lookup [open event/port]
        connect [write event/port to-binary "ping!"]
        wrote [
            print "Client sent ping to server"
            read event/port
        ]
        read [
            print ["Server said:" to-string event/port/data]
            if (++ ping-count) > 50 [return true]
            clear event/port/data
            write event/port to-binary "ping!"
        ]
    ]
    false
]
Andreas:
8-Jan-2010
graham, i need the awake handler in port/state/awake to be set, otherwise 
awake doesn't get called
Andreas:
8-Jan-2010
the smtp port's awake is never called
Andreas:
8-Jan-2010
ah, i see, you have the awake on the tcp port instead
Andreas:
9-Jan-2010
the wait in the read actor returns once the awake handler in the 
tcp subport returns true
Andreas:
9-Jan-2010
the second observation is that the return value of an awake handler 
seems to have no effect at all on scheduling
Andreas:
9-Jan-2010
a WAIT on the tcp port returns once the awake handler returns true; 
for any other return value, the WAIT keeps hanging on
Andreas:
9-Jan-2010
so in essence: write only buffers data to be sent, read schedules 
a port so that it awakes on events, wait blocks until awake returns 
true
Graham:
9-Jan-2010
You can only exit the awake handler by returning true ...
Andreas:
9-Jan-2010
and if you want for the awake handler to be called again, you need 
to be sure to read event/port
Andreas:
9-Jan-2010
now somewhen the awake handler will get called
Andreas:
9-Jan-2010
return false from the awake handler, but do _not_ re-schedule the 
port
Andreas:
9-Jan-2010
the WAIT will keep on blocking, but the port was not re-scheduled 
with a read, so the awake handler will never be called again
Andreas:
9-Jan-2010
to i think, awake should only finish with one of the following sequences:
1.) read event/port return false
2.) return true
Andreas:
9-Jan-2010
re the bind: i store the stuff the awake handler needs in order to 
work in port/locals
Graham:
10-Jan-2010
in the awake handler, there is a 'lookup event
Graham:
10-Jan-2010
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
Steeve:
10-Jan-2010
Should be enough

make-scheme [
	title: "Dns"
	name: 'dns2
	actor: [
		read: func [port [port!] /con][
			con: open [scheme: 'tcp host: port/spec/host]
			con/awake: func [event][true]
			wait [con 5]  ;*** timeout 5 secs
			attempt [get in query con 'remote-ip]
		]
	]
]
>>read dns2://www.rebol.net
216.240.11.203
Steeve:
10-Jan-2010
i encountered the famous stack overflow bug.

Never never use a [wait] when you treat an event in the awake handler
1 / 168[1] 2