Node:Server, Next:, Previous:Linda Library, Up:Linda Library



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 or linda/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, it is assumed to be an option of the form Address-Goal.

In SICStus before 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, the client is allowed to connect. If Goal fails, 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, 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.