ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent-MP/MP/Intro.pod
(Generate patch)

Comparing AnyEvent-MP/MP/Intro.pod (file contents):
Revision 1.55 by root, Thu Mar 22 00:48:29 2012 UTC vs.
Revision 1.56 by root, Thu Mar 22 23:47:02 2012 UTC

273network, often the same string as used for the C<binds> parameter of the 273network, often the same string as used for the C<binds> parameter of the
274other node. The need for seeds is easy to explain: I<somehow> the nodes 274other node. The need for seeds is easy to explain: I<somehow> the nodes
275of an aemp network have to find each other, and often this means over the 275of an aemp network have to find each other, and often this means over the
276internet. So broadcasts are out. 276internet. So broadcasts are out.
277 277
278Instead, a node usually specifies the addresses of a few (for redundancy) 278Instead, a node usually specifies the addresses of one or few (for
279other nodes, some of which should be up. Two nodes can set each other as 279redundancy) other nodes, some of which should be up. Two nodes can set
280seeds without any issues. You could even specify all nodes as seeds for 280each other as seeds without any issues. You could even specify all nodes
281all nodes, for total redundancy. But the common case is to have some more 281as seeds for all nodes, for total redundancy. But the common case is to
282or less central, stable servers running seed services for other nodes. 282have some more or less central, stable servers running seed services for
283other nodes.
283 284
284All you need to do to ensure that an AnyEvent::MP network connects 285All you need to do to ensure that an AnyEvent::MP network connects
285together is to make sure that all seed nodes are connected together via 286together is to make sure that all seed nodes are connected together via
286their seed connections, i.e., all connections from seed nodes to I<their> 287their seed connections, i.e., all connections from seed nodes to I<their>
287seed nodes form a connected graph. It's not necessary (but common) for a 288seed nodes form a connected graph.
288seed node to list all other seed nodes as seeds. The rest of the nodes in
289the network simply specify one or more of the seed nodes in their seed
290list.
291
292The simplest way to do that would be for all nodes to specify a single
293node as seed node, and you would get a star topology. If you specify all
294nodes as seed nodes, you get a fully meshed network (that's what previous
295releases of AnyEvent::MP actually did).
296 289
297A node tries to keep connections open to all of it's seed nodes at all 290A node tries to keep connections open to all of it's seed nodes at all
298times, while other connections are made on demand only. 291times, while other connections are made on demand only.
292
293The simplest way to do that would be for all nodes to use the same seed
294nodes: seed nodes would seed each other, and all other nodes would connect
295to the seed nodes.
299 296
300All of this ensures that the network stays one network - even if all the 297All of this ensures that the network stays one network - even if all the
301nodes in one half of the net are separated from the nodes in the other 298nodes in one half of the net are separated from the nodes in the other
302half by some network problem, once that is over, they will eventually 299half by some network problem, once that is over, they will eventually
303become a single network again. 300become a single network again.
670Without further ado, here is the chat server (to run it, we assume the 667Without further ado, here is the chat server (to run it, we assume the
671set-up explained earlier, with a separate F<aemp run seed> node): 668set-up explained earlier, with a separate F<aemp run seed> node):
672 669
673 use common::sense; 670 use common::sense;
674 use AnyEvent::MP; 671 use AnyEvent::MP;
675 use AnyEvent::MP::Global;
676 672
677 configure; 673 configure;
678 674
679 my %clients; 675 my %clients;
680 676
984new function, C<spawn>: 980new function, C<spawn>:
985#todo# 981#todo#
986 982
987 use common::sense; 983 use common::sense;
988 use AnyEvent::MP; 984 use AnyEvent::MP;
989 use AnyEvent::MP::Global;
990 985
991 my $nick = shift; 986 my $nick = shift;
992 987
993 configure; 988 configure;
994 989

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines