[REBOL] Re: Async Question
From: charles::wardell::dendrite::com at: 13-Nov-2004 11:05
In this case, It seems like I get the "dns success" message but that's
about it.
How should I be accessing this through the client. I am simply opening
up a rebol session and trying.
Testport: open/lines tcp://localhost:9000
Insert a "Hello World"
I have also tried
Do %atcp-protocol.r
Testport: open/lines atcp://localhost:9000
Insert a "Hello World"
Thanks
Charlie
port: open/lines/custom atcp://localhost:9000 [
awake [
foreach event port/locals/events [
either error? event [
close port ;close the atcp port
return true ;stop wait
][
switch/default event [
dns-failure [
close port ;close the atcp port
print "Cannot resolve the server name"
return true ;stop wait
]
dns [
print ["dns success:" port/host "="
port/sub-port/port-id]
]
max-retry [
close port ;close the atcp port
print "Can't connect to server"
return true ;stop wait
]
connect [
print "Ok, connected"
insert port "Hello world!"
]
read [
print ["Data read:" copy port]
]
write [
print "All data has been written"
]
close [
print "Peer closed the connection."
close port ;close the atcp port
return true ;stop wait
]
][
print "Unexpected event - should not happen"
close port
return true ;stop wait
]
]
]
false ;continue wait
]
]
wait-start port
wait-list?
forever [ wait [] ]