Schemes - r3n/rebol-wiki GitHub Wiki
A scheme specifies a type of port. Schemes are defined for files, networking, sound, and many other functions. Users can define their own schemes or modify the existing schemes.
The name scheme comes from the standard description of a URI (URL). In this URL:
http://www.rebol.net/index.htmlHTTP is the scheme name, www.rebol.net is the host, and index.html is the file path. Rebol uses that same naming convention.
A variety of schemes are built-into Rebol 3 and can be used immediately on boot.
Here is a partial list of built-in schemes:
| system | System port (primary event dispatcher) |
| stdio | Standard input and output |
| stderr | Standard error |
| console | Rebol interactive console |
| file | Local file access |
| dir | Local file directory access |
| event | GUI event handling |
| DNS | Domain name lookup |
| TCP | Transfer control protocol |
| UDP | User datagram protocol |
| HTTP | Hypertext transfer protocol |
| shell | External shell commands (call) |
| serial | Serial port access |
| USB | USB serial port access |
| mutex | Mutual exclusion locks |
More (such as FTP, SMTP, POP) will be included as time and user-base contributions permit.
To obtain a list of the current schemes, you can write:
probe words-of system/schemesor:
foreach val get system/schemes [print [val/name val/title]]The scheme object is defined in system/standard as:
scheme: context [
name: ; word of http, ftp, sound, etc.
title: ; user-friendly title for the scheme
spec: ; custom spec for scheme (if needed)
info: ; prototype info object returned from query
actor: ; standard action handler for scheme port functions
awake: ; standard awake handler for this scheme's ports
none
]Where:
- name
- Is the type of scheme. This is the word used in the first part of the URL, such as TCP, HTTP, FTP, etc.. It must be a valid Rebol word (e.g. cannot begin with a number).
- title
- Is the title of the scheme for user identification and documentation purposes.
- spec
- An object used to specify additional features of the scheme.
- info
- A prototype object that is instantiated for a query on the scheme.
- actor
- The handler function that processes standard actions a port of this scheme type. For example, open, close, read, write, etc.
- awake
- A callback function that is invoked when new events arrive for a port of this scheme type.
The make-scheme function creates a new scheme from a block object specification.
(show example)