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

[REBOL] Port probing Re:

From: holger:rebol at: 16-Oct-2000 20:41

On Mon, Oct 16, 2000 at 10:12:13PM -0500, [ptretter--charter--net] wrote:
> If I have to ports that I wait for data on how can I put them in a while or > forever loop without locking up the console. If I had a if statement > testing data received.
That depends on the type of port and the version of REBOL you use. Assuming tcp, udp or serial ports opened with /direct, you can wait for multiple ports with wait [port1 port2] which returns one of the ports if it has data, none otherwise. To get a block of all ports returned instead of just a single port use wait/all (latest experimental version only). To just poll ports without blocking add a timeout of zero, i.e. try wait [port1 port2 0] Using a timeout of zero to poll only works with some old (pre-2.3) versions of REBOL (on some platforms) and with the latest experimental versions (on all platforms), but not with REBOL 2.3. Other types of ports currently do not support 'wait. Higher-level network ports (HTTP etc.) will probably support it in one of the next experimental versions, when opened with /direct. You may also want to look at the no-wait refinement for 'open. It guarantees that 'copy on a port never blocks, even if there is no data available on it (latest experimental version only). -- Holger Kruse [holger--rebol--com]