REBOL 3 Docs Guide Concepts Functions Datatypes Errors
  TOC < Back Next >   Updated: 18-Feb-2009 Edit History  

REBOL 3 Concepts: Tour: Networking

Pending Revision

This document was written for R2 and has yet to be revised for R3.


This section is obsolete and being replaced. It is kept only as a source for new content.

There are a number of Internet protocols built into REBOL. These protocols are easy to use and require very little knowledge of networking.



The following example shows how to use the HTTP protocol to read a web page:

page: read

The next example fetches an image from a web page and writes it to a local file:

image: read/binary

write/binary %image.jpg image


The following reads and writes files to a server using the file transfer protocol (FTP):

file: read

write ftp://user:pass@site.dom/test.txt file

The next example gets a directory listing from FTP:

print read


The following example sends email with the simple mail transfer protocol (SMTP):

send "Use the force."

The next example sends the text of a file as an email:

send read %plan.txt


The following example fetches email with the post office protocol (POP) and prints all of the current messages but leaves them on the server:

foreach message read pop://user:pass@mail.dom [
    print message


The following example fetches news with the network news transfer protocol (NNTP), reading all of the news in a particular news group:

messages: read nntp://news.server.dom/comp.lang.rebol

The next example reads a list of all news group and prints them:

news-groups: read nntp://

foreach group news-groups [print group]


The following example gets the current time from a server:

print read daytime://


The following example finds out who is in charge of a domain using the whois protocol:

print read whois://


The following example gets user information with the finger protocol:

print read finger://username@host.dom


The following example determines an Internet address from a domain name and a domain name from an address:

print read dns://

print read dns://


Direct connections with TCP/IP are also possible in REBOL. The following example is a simple, but useful, server that waits for connections on a port, then executes whatever has been sent:

server-port: open/lines tcp://:9999

forever [
    connection-port: first server-port
    until [
        wait connection-port
        error? try [do first connection-port]
    close connection-port

  TOC < Back Next > - WIP Wiki Feedback Admin