REBOL Technologies

What is the system/ports/timeout-list?

Carl Sassenrath, CTO
REBOL Technologies
20-Nov-2004

Article #0054
Main page || Index || Prior Article [0053] || Next Article [0055] || Post Comments || Send feedback

Some developers have discovered the system/ports/timeout-list in the new REBOL releases (the async kernels). Like other areas of the system object, this is an internal structure used by the REBOL implementation. It's one of those "never mind the man behind the curtain" types of things.

The timeout-list is used by the SET-MODES function to keep track of timer information when you add a TIMEOUT mode to a port. For example, in the code below:

port: open/direct/binary/async tcp://www.rebol.net:80 :handler
set-modes port [timeout: 30]

the SET-MODES function sets the port's timeout to 30 seconds. If nothing happens in 30 seconds, the port will throw an error. Note that you can also set the timeout within the various callback phases of your async handler. For example, you might set a long timeout for the initial TCP open then shorten the timeout for the read and write operations.

Of course, port timeouts accept the normal range of time values that you would use with the WAIT function:

timeout: 30      ; seconds
timeout: 3.5     ; seconds
timeout: 0:10:00 ; minutes

And you can remove the timeout by setting it to NONE, as in this line:

set-modes port [timeout: none]

Also note that if you want to change a timeout value, you must first remove the prior timeout before setting it to a new value.

set-modes c-port [timeout: none timeout: 10]

Yes, this seems a bit silly to us too. We'd like to fix it before the async version is released and allow the removal to be implied. But, if you need it today, there it is -- and it will be compatible with our future change.

As for the system/ports/timeout-list itself, as with other internal bookkeeping structures please do not mess with it. Use the SET-MODES function described above.

Post Comments

Updated 21-Nov-2024   -   Copyright Carl Sassenrath   -   WWW.REBOL.COM   -   Edit   -   Blogger Source Code