---
name: "Spread"
section: "3pm"
platform: "linux"
package: "libspread-perl"
version: "3.17.4-2+b1"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/Spread"
---

# Spread(3pm)

Perl extension for the Spread group communication system

## NAME

Spread - Perl extension for the Spread group communication system

## SYNOPSIS

```
  use Spread;
  # Connect
  my($mailbox, $private_group) = Spread::connect(
        spread_name => '4444@host.domain.com',
        private_name => 'mrcool',
        );
  # Join and leave groups
  my(@group_to_join) = ( 'GroupA', 'GroupB', 'GroupC' );
  my(@joined_groups) = grep( Spread::join($mbox, $_), @group_to_join );
  print "Spread::join -- $sperrorno"
        unless (Spread::leave($mbox, 'GroupC'));
  # Multicast to group(s)
  Spread::multicast($mbox, AGREED_MESS, 'GroupB', 0, "Hey you!");
  Spread::multicast($mbox, SAFE_MESS, @joined_groups, 0, "Hey yall!");
  # Poll mailbox
  my($messsize) = Spread::poll($mbox);
  if(defined($messsize)) { print "Next message: $messsize bytes\n"; }
  else { print "Spread::poll $sperrno\n"; }
  # Receive messages (see spread's man pages for more description)
  my($service_type, $sender, $groups, $mess_type, $endian, $message) =
        Spread::receive($mbox);
  my($service_type, $sender, $groups, $mess_type, $endian, $message) =
        Spread::receive($mbox, 1.789);  # 1.789 second timeout on receive
  # Disconnect
  if(Spread::disconnect($mbox)) { print "Successful disconnect\n"; }
  else { print "Spread::disconnect -- $sperrorno\n"; }
```

## DESCRIPTION

Understanding through practice ;)

See man pages for SP\_connect, SP\_join, SP\_multicast, SP\_receive, SP\_poll, SP\_error, SP\_leave, SP\_disconnect.

`$sperror` holds either the integer spread error or a descriptive string depending on the context in which `$sperror` is used.

## Exported constants

The predefined groups of exports in the use statements are as follows:

use Spread qw(:SP);

Exports the Spread::connect, Spread::join, Spread::multicast, Spread::receive, Spread::poll, Spread::error, Spread::leave, and Spread::disconnect as SP\_connect, SP\_join, SP\_multicast, SP\_receive, SP\_poll, SP\_error, SP\_leave, and SP\_disconnect, respectively.

use Spread qw(:ERROR);

Exports all of the error conditions.  Please refer to the SP\_\* C man pages as the "RETURN VALUES" there have both identical spellings and meanings.

use Spread qw(:MESS);

Exports all of the message types (this is returned as service type by the Spread::receive function and is the request service type of the Spread::multicast function).  The actual meaning of these orderings and assurances are not simple to explain without a basic understanding of group communication systems.  For more information on this topic, please visit the Spread web site at http://www.spread.org/

All constants in alphabetical order:

```
  ACCEPT_SESSION
  AGREED_MESS
  BUFFER_TOO_SHORT
  CAUSAL_MESS
  CAUSED_BY_DISCONNECT
  CAUSED_BY_JOIN
  CAUSED_BY_LEAVE
  CAUSED_BY_NETWORK
  CONNECTION_CLOSED
  COULD_NOT_CONNECT
  FIFO_MESS
  HIGH_PRIORITY
  ILLEGAL_GROUP
  ILLEGAL_MESSAGE
  ILLEGAL_SERVICE
  ILLEGAL_SESSION
  ILLEGAL_SPREAD
  LOW_PRIORITY
  MAX_SCATTER_ELEMENTS
  MEDIUM_PRIORITY
  MEMBERSHIP_MESS
  REGULAR_MESS
  REG_MEMB_MESS
  REJECT_ILLEGAL_NAME
  REJECT_NOT_UNIQUE
  REJECT_NO_NAME
  REJECT_QUOTA
  REJECT_VERSION
  RELIABLE_MESS
  SAFE_MESS
  SELF_DISCARD
  TRANSITION_MESS
  UNRELIABLE_MESS
```

## AUTHOR

Theo Schlossnagle \<jesus@cnds.jhu.edu\>

## SEE ALSO

Various spread documentation at http://www.spread.org/.
