category

linda_server

Linda server predicates and tuple-space state. Import into a threaded object together with the linda_client category.

Availability:
logtalk_load(linda(loader))
Author: Paulo Moura
Version: 2:0:0
Date: 2026-03-27
Compilation flags:
static
Remarks:
(none)
Inherited public predicates:
(none)

Public predicates

linda/1

Starts a Linda server with the given options. The predicate succeeds when all clients have disconnected after a shutdown request.

Compilation flags:
static
Template:
linda(Options)
Meta-predicate template:
linda(::)
Mode and number of proofs:
linda(+list) - one
Remarks:
  • Option port(Port): Use Port as the server port. Must be an integer and an available port.

  • Option Address-Goal: Address is unified with Host:Port and Goal is called when the server starts. Useful for saving the address or starting clients.

  • Option accept_hook(Client,Input,Output,Goal): When a client connects, Client is unified with the client address, Input and Output with the connection streams, and Goal is called. If Goal fails, the connection is rejected.


linda/0

Starts a Linda server on an automatically assigned port using default options. The server address (Host:Port) is written to the current output stream. The predicate succeeds when all clients have disconnected after a shutdown request.

Compilation flags:
static
Mode and number of proofs:
linda - one

Protected predicates

(no local declarations; see entity ancestors if any)

Private predicates

server_socket_/1

Stores the server socket descriptor.

Compilation flags:
dynamic
Template:
server_socket_(ServerSocket)
Mode and number of proofs:
server_socket_(?term) - zero_or_one

client_connection_/3

Stores active client connections. Each client has an ID, input stream, and output stream.

Compilation flags:
dynamic
Template:
client_connection_(ClientId,InputStream,OutputStream)
Mode and number of proofs:
client_connection_(?term,?term,?term) - zero_or_more

accept_hook_/1

Stores the optional accept hook goal to call when a client connects.

Compilation flags:
dynamic
Template:
accept_hook_(Hook)
Mode and number of proofs:
accept_hook_(?callable) - zero_or_one

server_running_/1

Flag indicating the server is running.

Compilation flags:
dynamic
Template:
server_running_(Address)
Mode and number of proofs:
server_running_(?address) - zero_or_one

server_shutdown_/0

Flag indicating the server has received a shutdown request.

Compilation flags:
dynamic
Mode and number of proofs:
server_shutdown_ - zero_or_one

tuple_/1

Stores tuples in the Linda tuple space.

Compilation flags:
dynamic
Template:
tuple_(Tuple)
Mode and number of proofs:
tuple_(?term) - zero_or_more

waiting_/3

Stores blocked clients waiting for tuples. Records the client ID, request pattern, and output stream.

Compilation flags:
dynamic
Template:
waiting_(ClientId,Request,OutputStream)
Mode and number of proofs:
waiting_(?term,?term,?term) - zero_or_more

client_engine_/2

Maps client IDs to their corresponding threaded engine names.

Compilation flags:
dynamic
Template:
client_engine_(ClientId,EngineName)
Mode and number of proofs:
client_engine_(?term,?atom) - zero_or_more

ts_out/1

Synchronized predicate to add a tuple to the tuple space and wake waiting clients.

Compilation flags:
static, synchronized
Template:
ts_out(Tuple)
Mode and number of proofs:
ts_out(+term) - one

ts_in/4

Synchronized predicate to remove a matching tuple or register a waiting client.

Compilation flags:
static, synchronized
Template:
ts_in(Tuple,ClientId,OutputStream,Found)
Mode and number of proofs:
ts_in(+term,+term,+term,-compound) - one

ts_in_noblock/2

Synchronized predicate to try removing a matching tuple without blocking.

Compilation flags:
static, synchronized
Template:
ts_in_noblock(Tuple,Found)
Mode and number of proofs:
ts_in_noblock(+term,-compound) - zero_or_one

ts_in_list/4

Synchronized predicate to remove a tuple matching one of multiple patterns or register a waiting client.

Compilation flags:
static, synchronized
Template:
ts_in_list(TupleList,ClientId,OutputStream,Found)
Mode and number of proofs:
ts_in_list(+list,+term,+term,-compound) - one

ts_rd/4

Synchronized predicate to read a matching tuple or register a waiting client.

Compilation flags:
static, synchronized
Template:
ts_rd(Tuple,ClientId,OutputStream,Found)
Mode and number of proofs:
ts_rd(+term,+term,+term,-compound) - one

ts_rd_noblock/2

Synchronized predicate to try reading a matching tuple without blocking.

Compilation flags:
static, synchronized
Template:
ts_rd_noblock(Tuple,Found)
Mode and number of proofs:
ts_rd_noblock(+term,-compound) - zero_or_one

ts_rd_list/4

Synchronized predicate to read a tuple matching one of multiple patterns or register a waiting client.

Compilation flags:
static, synchronized
Template:
ts_rd_list(TupleList,ClientId,OutputStream,Found)
Mode and number of proofs:
ts_rd_list(+list,+term,+term,-compound) - one

ts_findall_rd_noblock/3

Synchronized predicate to collect all tuples matching a pattern.

Compilation flags:
static, synchronized
Template:
ts_findall_rd_noblock(Template,Tuple,List)
Mode and number of proofs:
ts_findall_rd_noblock(+term,+term,-list) - zero_or_more

ts_findall_in_noblock/3

Synchronized predicate to collect and remove all tuples matching a pattern.

Compilation flags:
static, synchronized
Template:
ts_findall_in_noblock(Template,Tuple,List)
Mode and number of proofs:
ts_findall_in_noblock(+term,+term,-list) - zero_or_more

Operators

(none)