Beruflich Dokumente
Kultur Dokumente
1. Introduction
This tutorial covers networking in DrScheme/MzScheme via the TCP (Transmission
Control Protocol) protocol. TCP offers the possibility to transfer data between
programs running on different computers.
We begin by describing Peer-to-Peer connections and continue with the Client-
Server Model.
2. Conventions
The following conventions are used throughout this document.
For description of procedure headers, brackets ([ ]) are used to indicate optional
parameters.
Sometimes only relevant parameters are listed for a procedure. For a full
parameter listing, refer to the MzScheme Language Manual on the PLT homepage
or in the DrScheme Help Desk.
Italics are used when introducing new terms.
Constant width is used for code examples, procedures, symbols and other things
that appear in code.
3. The Basics
To establish a connection between two computers via TCP, one computer need to
act as a client, and the other needs to act as a server. The idea is that the client
connects to the server to establish a connection. To be able to do this, the client
needs to know the IP- address of the server, and which port the server is listening
on. The IP-address can be in the form of a hostname or URL, like “ida.liu.se”, or in
the form of a (currently) 32-bit number written in dotted form like 130.236.177.26.
A port can be any number between 1 and 65535, however some of the lower
numbered ports are reserved. For example, 20-21 is for FTP access, 22 for SSH, 23
for TELNET, 25 for SMTP and 80 for HTTP. To avoid problems, use a port number
above 1000.
For example, if we want a browser to view
the web page at http://www.ida.liu.se, the
URL would be www.ida.liu.se, and as it is a
http connection it would use port 80.
5. Peer-to-Peer Example
See p2pchat.scm
7. Client-Server Example
A simple chat server is implemented in server-example.scm, and a even simpler
chat client is implemented in client-example.scm. To get started, examine those
files and you should have enough knowledge to do your own network applications.
8. Comments?
Typos, corrections, questions and/or other comments can be sent to Joakim
Hellsten, joahe@ida.liu.se.