[REBOL] Re: Creating a Server Port Cookbook example - newbie question
From: g:santilli:tiscalinet:it at: 14-Oct-2003 10:29
Hi David,
On Tuesday, October 14, 2003, 1:08:01 AM, you wrote:
DG> listen: open tcp://:12345
DG> waitports: [listen]
DG> forever [
DG> data: wait waitports
DG> either same? data listen [
DG> active-port: first listen
DG> append waitports active-port
DG> ][
DG> incoming-from-remote: first data
DG> print incoming-from-remote
DG> ]
DG> ]
I'd do it as:
listen: open/no-wait tcp://:12345
waitports: [listen]
forever [
port: wait waitports
either same? port listen [
active-port: first listen
append waitports active-port
] [
incoming-from-remote: copy port
either incoming-from-remote [
prin incoming-from-remote
] [
remove find waitports port
close port
]
]
]
(Well, actually I'd do it event-based, but maybe this way it is
more appropriate for a cookbook.)
Regards,
Gabriele.
--
Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer
Amiga Group Italia sez. L'Aquila --- SOON: http://www.rebol.it/