A client can register a name with the Pedro server. This name can be used
by other registered clients to provide peer-to-peer communication.
This is done by sending the following string (with a newline termination)
to the Pedro server (where
name is the name being registered).
The registered name must be an atom not containing the
:' and '
The server will acknowledge the client with a 1 if the registration succeeds and a 0 otherwise.
Semantically, a registration is the same as a restricted form of subscription. Specifically, a registration can be thought of as a subscription of the following form.
subscribe(p2pmsg(_:name@machine, _, _), true, 0)
name is the name being registered (the name of this process) and
machine is the name of the machine on which the process is running.
The restriction is that at most one process on any given machine can register a
The idea is that a notification of the form
p2pmsg(ToAddr, MyAddr, Msg)
MyAddr are addresses of the form
ID:Name@Machine will match a registration subscription if the
ToAddr of the notification unifies with the first argument of the subscription.
ID part of an address is optional and is ignored by the Pedro
server. It is up to the clients to determine how this argument is used.
This might be, for example, used as the name of a thread or message queue.
The rock used when sending such
notifications to clients is always set to
The ID part of an address can be elided from the notification if it is not required. It is up to the clients to determine what to do if no ID is supplied.
Machine parts of
ToAddr are either atoms
or variables. The characters '
:' and '
@' are not
allowed to appear in
Machine. It is also possible
ToAddr to be a variable in which case the semantics is the same as
having an address with both
Name is a variable then the notification will be sent to all registered processes on that machine. If
Machine is a variable then the notification will be sent to all processes with that registered name. If both are variables then the notification will be sent to all registered processes on all machines
that have registered processes.
MyAddr can be any valid address, but in practice the client
should make sure that this is its address. It will typically be used by
the receiving client when responding to a message.
p2pmsg(foo@'foo.com.au', bar@'bar.com.au', info(fred, [1,2,3])) is intended for the process with registered name
'foo.com.au' (note that the process name and machine name must both
This client is registered with the name