[REBOL] Re: Async Question
From: charles:wardell:dendrite at: 13-Nov-2004 11:03
I have been playing with Both the async-protocol and the atcp-protocol
with no real success. I will post the atcp snippet in the next email.
When using the async-protocol, it seems like the event handler never
kicks off but the listen/awake function kicks seems to accept at least 1
connection because it prints "connection"
Any suggestions?
Rebol [
Title: none
]
do %/d/projects/rebol/async-protocol.r
either error? try [listen: open/no-wait tcp://:8000] [
port: open async://localhost:8000
port/awake: do handler
] [
listen/awake: func [l /local p] [
print "connection"
p: first listen
remove find system/ports/wait-list listen
port: make port! [scheme: 'async sub-port: p]
open port
port/awake: do handler
false
]
insert tail system/ports/wait-list listen
port: none
]
handler: [use [ buffer ] [
buffer: copy []
func [port [port!] state [word! error!] /local tmp cmd] [
if error? :state [print mold disarm state return true]
switch state [
connect [print "connected event"]
read [
append buffer copy port
while [tmp: find buffer newline] [
cmd: copy/part buffer tmp
remove/part buffer next tmp
print cmd
]
false
]
write [false]
close [print "Connection Closed. " close port true]
]
]
]
]
forever [wait []]