|
NAMESpread - Perl extension for the Spread group communication systemSYNOPSISuse Spread; # Connect my($mbox, $private_group) = Spread::connect( { spread_name => '4444@host.domain.com', private_name => 'mrcool', } ); # If you don't give a private name, you'll get a unique name from the spread daemon. my($mailbox, $private_group) = Spread::connect( spread_name => '4444@host.domain.com', ); # Join and leave groups my(@group_to_join) = ( 'GroupA', 'GroupB', 'GroupC' ); my(@joined_groups) = grep( Spread::join($mbox, $_), @group_to_join ); print "Spread::join -- $sperrno" 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 -- $sperrno\n"; } DESCRIPTIONUnderstanding through practice ;)See man pages for SP_connect, SP_join, SP_multicast, SP_receive, SP_poll, SP_error, SP_leave, SP_disconnect. $sperrno holds either the integer spread error or a descriptive string depending on the context in which $sperrno is used. Exported constantsThe 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_MESS REJECT_NOT_UNIQUE REJECT_NO_NAME REJECT_QUOTA REJECT_VERSION RELIABLE_MESS SAFE_MESS SELF_DISCARD TRANSITION_MESS UNRELIABLE_MESS AUTHORTheo Schlossnagle <jesus@cnds.jhu.edu>SEE ALSOVarious spread documentation at http://www.spread.org/.
Visit the GSP FreeBSD Man Page Interface. |