Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: The REBOL async:// tutorial - take 1

From: tbrownell:veleng at: 4-Mar-2004 2:21

I was misunderstood.. what I meant was, once I get some stuff FROM read.. and do some magic with it (ie: get the result of 2 + 2).. how do I send the RESULT back to the client via WRITE? I dont have a problem with getting or processing READ. Terry 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