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.

OLD DOCS

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.

Contents

HTTP

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

page: read http://www.rebol.com

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

image: read/binary http://www.page.dom/image.jpg

write/binary %image.jpg image

FTP

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

file: read ftp://ftp.rebol.com/test.txt

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

The next example gets a directory listing from FTP:

print read ftp://ftp.rebol.com/pub

SMTP

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

send luke@rebol.com "Use the force."

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

send luke@rebol.com read %plan.txt

POP

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
]

NNTP

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://news.some-isp.net

foreach group news-groups [print group]

Daytime

The following example gets the current time from a server:

print read daytime://everest.cclabs.missouri.edu

Whois

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

print read whois://rebol@rs.internic.net

Finger

The following example gets user information with the finger protocol:

print read finger://username@host.dom

DNS

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

print read dns://www.rebol.com

print read dns://207.69.132.8

TCP

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 > REBOL.com - WIP Wiki Feedback Admin