[REBOL] Re: The REBOL async:// tutorial - take 1
From: maarten:vrijheid at: 4-Mar-2004 11:02
Terry Brownell wrote:
>Excellent.. finally some light in this dark hole of tcp.
>
>I have a couple of questions though.. in the handler we have connect,
>read, write close.. how can i do this...
>
>connect []
>read [ (read the buffer, which in this case is "2 + 2", and having
>processed this to a result string of "4"...)]
>write [... send the result back?]
>close []
>
terminate the string by a newline.
inbuf your input buffer from the use context:
read [
append inbuf copy port
if found? find inbuf newline [
do copy/part inbuf find inbuf newline
remove/part inbuf -1 + index? find inbuf newline
]
]
>And my second question.. what does it take to handle multiple clients,
>and have the server continue to serve, rather than shutting down when
>the client disconnects?
>
Nothing. Every connection gets a client port with this handler from the
server port. That's the beauty of it. And multiplexing is done by a
state machine based on the event per port, hence the name "async".
--Maarten