Skip to content

scymtym/network.spread

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

network.spread README

Introduction

The network.spread system provides Common Lisp bindings for the client library of the Spread group communication system.

https://travis-ci.org/scymtym/network.spread.svg

Tutorial

Connecting

When using Spread, the first step usually consists in establishing a connection to the Spread daemon. The following example demonstrates this for a situation in which the Spread daemon is running on the local machine and listening on port 4803 (the default port):

(defvar *connection* (network.spread:connect "4803"))

Receiving Messages

After a connection has been established, data can be sent and received. However, in order to receive data, it is necessary to join the Spread group to which messages are sent. In the following code, the previously created connection joins a Spread group called =”mygroup”=. The number of groups a given connection is a member of is evident from the printed representation of the connection instance.

(network.spread:join *connection* "mygroup")

After joining one ore more groups, messages can be received:

(network.spread:receive *connection* :block? nil)

Consing can be avoided by receiving into a previously allocated buffer:

(defvar *buffer* (nibbles:make-octet-vector 10000))

(network.spread:receive-into *connection* *buffer*)

Sending Messages

To send data to receivers in a Spread group, the generic functions network.spread:send and network.spread:send-bytes are used (the delegates the actual work to the latter):

(network.spread:send *connection* "mygroup" "mymessage")

Note that it is not necessary to join a Spread group in order to send messages to that group.

It is possible to send a single message to multiple groups:

(network.spread:send *connection* '("mygroup" "othergroup") "mymessage")

Settings

About

Common Lisp bindings for Spread client API

Resources

License

Stars

Watchers

Forks

Packages

No packages published