Next: , Up: lib-linda   [Contents][Index]


10.24.1 Linda Server

The server is the process running the “blackboard process”. It is an ordinary SICStus process, which can be run on a separate machine if necessary.

To load the package, enter the query

| ?- use_module(library('linda/server')).

and start the server with linda/[0,1].

linda

Starts a Linda-server in this SICStus. The network address is written to the current output stream as Host:PortNumber.

linda(:Options)

Starts a Linda-server in this SICStus. Each option on the list Options is one of

Address-Goal

where Address must be unifiable with Host:Port and Goal must be instantiated to a goal.

When the linda server is started, Host and Port are bound to the server host and port respectively and the goal Goal is called. A typical use of this would be to store the connection information in a file so that the clients can find the server to connect to.

For backward compatibility, if Options is not a list, then it is assumed to be an option of the form Address-Goal.

Before release 3.9.1, Goal needed an explicit module prefix to ensure it was called in the right module. This is no longer necessary since linda/1 is now a meta-predicate.

accept_hook(Client,Stream,Goal)

When a client attempts to connects to the server Client and Stream will be bound to the IP address of the client and the socket stream connected to the client, respectively. The Goal is then called, and if it succeeds, then the client is allowed to connect. If Goal fails, then the server will close the stream and ignore the connection request. A typical use of this feature would be to restrict the addresses of the clients allowed to connect. If you require bullet proof security, then you would probably need something more sophisticated.

Example:

| ?- linda([(Host:Port)-mypred(Host,Port), 
            accept_hook(C,S,should_accept(C,S))]).

will call mypred/2 when the server is started. mypred/2 could start the client-processes, save the address for the clients etc. Whenever a client attempts to connect from a host with IP address Addr, a bi-directional socket stream Stream will be opened to the client, and should_accept(Addr,Stream) will be called to determine if the client should be allowed to connect.



Send feedback on this subject.