… | |
… | |
11 | NODE $port # returns the noderef of the port |
11 | NODE $port # returns the noderef of the port |
12 | |
12 | |
13 | $SELF # receiving/own port id in rcv callbacks |
13 | $SELF # receiving/own port id in rcv callbacks |
14 | |
14 | |
15 | # initialise the node so it can send/receive messages |
15 | # initialise the node so it can send/receive messages |
16 | initialise_node; # -OR- |
16 | initialise_node; |
17 | initialise_node "localhost:4040"; # -OR- |
|
|
18 | initialise_node "slave/", "localhost:4040" |
|
|
19 | |
17 | |
20 | # ports are message endpoints |
18 | # ports are message endpoints |
21 | |
19 | |
22 | # sending messages |
20 | # sending messages |
23 | snd $port, type => data...; |
21 | snd $port, type => data...; |
… | |
… | |
72 | A port is something you can send messages to (with the C<snd> function). |
70 | A port is something you can send messages to (with the C<snd> function). |
73 | |
71 | |
74 | Ports allow you to register C<rcv> handlers that can match all or just |
72 | Ports allow you to register C<rcv> handlers that can match all or just |
75 | some messages. Messages will not be queued. |
73 | some messages. Messages will not be queued. |
76 | |
74 | |
77 | =item port id - C<noderef#portname> |
75 | =item port ID - C<noderef#portname> |
78 | |
76 | |
79 | A port ID is the concatenation of a noderef, a hash-mark (C<#>) as |
77 | A port ID is the concatenation of a noderef, a hash-mark (C<#>) as |
80 | separator, and a port name (a printable string of unspecified format). An |
78 | separator, and a port name (a printable string of unspecified format). An |
81 | exception is the the node port, whose ID is identical to its node |
79 | exception is the the node port, whose ID is identical to its node |
82 | reference. |
80 | reference. |
… | |
… | |
89 | |
87 | |
90 | Nodes are either private (single-process only), slaves (can only talk to |
88 | Nodes are either private (single-process only), slaves (can only talk to |
91 | public nodes, but do not need an open port) or public nodes (connectable |
89 | public nodes, but do not need an open port) or public nodes (connectable |
92 | from any other node). |
90 | from any other node). |
93 | |
91 | |
94 | =item noderef - C<host:port,host:port...>, C<id@noderef>, C<id> |
92 | =item node ID - C<[a-za-Z0-9_\-.:]+> |
95 | |
93 | |
96 | A node reference is a string that either simply identifies the node (for |
94 | A node ID is a string that either simply identifies the node (for |
97 | private and slave nodes), or contains a recipe on how to reach a given |
95 | private and slave nodes), or contains a recipe on how to reach a given |
98 | node (for public nodes). |
96 | node (for public nodes). |
99 | |
97 | |
100 | This recipe is simply a comma-separated list of C<address:port> pairs (for |
98 | This recipe is simply a comma-separated list of C<address:port> pairs (for |
101 | TCP/IP, other protocols might look different). |
99 | TCP/IP, other protocols might look different). |
… | |
… | |
144 | } |
142 | } |
145 | |
143 | |
146 | =item $thisnode = NODE / $NODE |
144 | =item $thisnode = NODE / $NODE |
147 | |
145 | |
148 | The C<NODE> function returns, and the C<$NODE> variable contains the |
146 | The C<NODE> function returns, and the C<$NODE> variable contains the |
149 | noderef of the local node. The value is initialised by a call to |
147 | node id of the local node. The value is initialised by a call to |
150 | C<initialise_node>. |
148 | C<initialise_node>. |
151 | |
149 | |
152 | =item $noderef = node_of $port |
150 | =item $nodeid = node_of $port |
153 | |
151 | |
154 | Extracts and returns the noderef from a port ID or a noderef. |
152 | Extracts and returns the noderef from a port ID or a node ID. |
155 | |
153 | |
156 | =item initialise_node $noderef, $seednode, $seednode... |
154 | =item initialise_node $profile_name |
157 | |
|
|
158 | =item initialise_node "slave/", $master, $master... |
|
|
159 | |
155 | |
160 | Before a node can talk to other nodes on the network it has to initialise |
156 | Before a node can talk to other nodes on the network it has to initialise |
161 | itself - the minimum a node needs to know is it's own name, and optionally |
157 | itself - the minimum a node needs to know is it's own name, and optionally |
162 | it should know the noderefs of some other nodes in the network. |
158 | it should know the noderefs of some other nodes in the network. |
163 | |
159 | |