Next: , Previous: Removing Subscriptions, Up: Top

7 Registrations

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 characters ',', ':' 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)

where 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 given name.

The idea is that a notification of the form

p2pmsg(ToAddr, MyAddr, Msg)

where ToAddr and 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.

The 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 0.

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.

The Name and Machine parts of ToAddr are either atoms or variables. The characters ',', ':' and '@' are not allowed to appear in Name or Machine. It is also possible for ToAddr to be a variable in which case the semantics is the same as having an address with both Name and Machine variables.

If 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.

Note that 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.


The notification p2pmsg(foo@'', bar@'', info(fred, [1,2,3])) is intended for the process with registered name foo on '' (note that the process name and machine name must both be atoms). This client is registered with the name bar.