Previous: , Up: Configuring Serveez   [Contents][Index]


1.5.3 Bind servers to ports

Finally you can bind servers to ports. When you do so the server you created listens on the port, accepts connections and serves clients. It does so as soon as Serveez enters its main loop right after running the configuration file. Serveez won’t stop until you interrupt it (e.g., by pressing ^C in the terminal you started it in).

This example binds the server foo-server (s.a.) to the port foo-tcp-port which was described above. Therefore you need to call the procedure bind-server! which takes two arguments specifying the name of a port configuration and a server instance. Both need to be defined before you can write this statement.

(bind-server! 'foo-tcp-port 'foo-server)

One of the main features of Serveez is that you can bind multiple servers to the same port. This for example is useful to pass braindead firewall configurations or proxy servers. It is also possible to bind servers to ports they are actually not designed for. This might be used for debugging servers or other funny things (again, think about the firewall). This is the point we have to warn you: Some protocols cannot share the same port (e.g., the tunnel server) and some protocols simply won’t work on ’wrong’ ports. Additionally, you will not get error messages when that happens. The server just will not work then.

1.5.4 Additional configuration possibilities

The three procedures define-port!, define-server! and bind-server! return #t on success and #f on failure. For your convenience we provide some more built-in procedures, some of which are based upon those above.

1.5.4.1 output

Scheme Procedure: fs s [args…]

Return a string made by applying simple-format #f to s and args. For example:

(fs "~A-~S" 'foo 42)
⇒ "foo-42"
Scheme Procedure: println [object…]

Do display on each object. Then, output a newline.

Scheme Procedure: printsln spacer [object…]

For each object, do display on it and on spacer, as well. Then, output a newline.

1.5.4.2 augmenting

Scheme Procedure: interface-add! interface

Add interface to the list of known network interfaces. You can get the list of known interfaces by running the shell command ‘serveez -i’. The interface argument must be in dotted decimal form (e.g., ‘127.0.0.1’). Serveez provides this procedure for systems where it is unable to detect the list of network interface automatically.

Scheme Procedure: loadpath-add! [dir…]

Append dir… to the server modules load path.

Scheme Procedure: serveez-load filename

Try to load filename (via primitive-load). If filename is not absolute, search for it in the list of directories returned by serveez-loadpath. Return #t if successful, #f otherwise.

1.5.4.3 abstractions

Scheme Procedure: bind-servers! [args…]

Bind all servers and ports in args to each other. This is a cross-product operation; given s servers, and p ports, s * p bindings will be created.

Scheme Procedure: create-tcp-port! basename port

Define a new TCP port named by concatenating basename and port. Return the new name.

Scheme Procedure: bind-tcp-port-range! from to [servers…]

Bind the list of servers to simple TCP port configurations whose network ports range between from and to both inclusive.

Scheme Procedure: create-udp-port! basename port

Define a new UDP port named by concatenating basename and port. Return the new name.

Scheme Procedure: bind-udp-port-range! from to [servers…]

Bind the list of servers to simple UDP port configurations whose network ports range between from and to both inclusive.

1.5.4.4 rpc

Scheme Procedure: getrpcent

Return the next RPC entry as a vector of the form: #(name aliases program-number). name is a symbol, aliases is a list (possibly empty) of symbols, and program-number is an integer. If the list is exhausted, return #f.

Scheme Procedure: getrpcbyname name

Return the RPC entry for name, a string. (FIXME: Should be able to handle a symbol, too.) If no such service exists, signal error.

Scheme Procedure: getrpcbynumber number

Return the RPC entry for number, an integer. If no such service exists, signal error.

Scheme Procedure: setrpcent [stayopen]

Open and rewind the file /etc/rpc. If optional arg stayopen (an integer) is non-zero, the database will not be closed after each call to getrpc (or its derivatives getrpcent, getrpcbyname, getrpcbynumber).

Scheme Procedure: endrpcent

Close the file /etc/rpc.

1.5.4.5 misc

Scheme Procedure: serveez-verbosity [level]

Return the verbosity level (an integer). Optional arg level means set it to that level, instead. This setting is overridden by the command-line ‘-v’ option.

Scheme Procedure: serveez-maxsockets [max]

Return the maximum number of open sockets permitted (an integer). Optional arg max means set it to that number, instead. This setting is overridden by the command-line ‘-m’ option.

Scheme Procedure: serveez-passwd [pw]

Return the control password (a string). Optional arg pw sets it to that, instead. This effectively does nothing if the control protocol is not enabled.

We now have a closer look at the internals of Serveez. If you are not interested in that have a look at the existing servers (See Existing servers.).


Previous: Define servers, Up: Configuring Serveez   [Contents][Index]