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

[REBOL] Re: Port checking and timers

From: holger:rebol at: 26-Nov-2000 12:01

On Sun, Nov 26, 2000 at 07:12:56PM +0000, Mat Bettinson wrote:
> Hello, > > I've got a rudimentary IRC bot working in Rebol. However it's all a > hideous kludge because the only way I've seen to check to see if a > port has data is to wait for it. > > Is there a more elegant way? Would empty? <port> work on a low-level > TCP port?
No. empty? can only be used with ports that are buffered into a series, not with "direct" ports. With current experimentals you can use wait [port 0] to check if a direct port has data. Alternatively, if you opened your port with /no-wait you can just copy from the port (without blocking) to get all data waiting at the port.
> Also, is there any built-in time type functions or do you have to > build your own based off now/time? (with resolution only as accurate > as a second).
The resolution of the time! datatype is one nanosecond. To get the current date/time with the highest possible resolution provided by the operating system use now/precise (with current experimentals only). If you only need the time, without the date, use now/precise/time. The exact resolution depends on the platform, but is one microsecond in most cases. -- Holger Kruse [holger--rebol--com]