| 62 | |
| 63 | |
| 64 | void send_out_connection_orders ( |
| 65 | map_id_to_con& cons, |
| 66 | const std::vector<network_address>& hosts |
| 67 | ) |
| 68 | { |
| 69 | // tell everyone their node ids |
| 70 | cons.reset(); |
| 71 | while (cons.move_next()) |
| 72 | { |
| 73 | dlib::serialize(cons.element().key(), cons.element().value()->stream); |
| 74 | } |
| 75 | |
| 76 | // now tell them who to connect to |
| 77 | std::vector<hostinfo> targets; |
| 78 | for (unsigned long i = 0; i < hosts.size(); ++i) |
| 79 | { |
| 80 | hostinfo info(hosts[i], i+1); |
| 81 | |
| 82 | dlib::serialize(targets, cons[info.node_id]->stream); |
| 83 | targets.push_back(info); |
| 84 | |
| 85 | // let the other host know how many incoming connections to expect |
| 86 | const unsigned long num = hosts.size()-targets.size(); |
| 87 | dlib::serialize(num, cons[info.node_id]->stream); |
| 88 | cons[info.node_id]->stream.flush(); |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | // ------------------------------------------------------------------------------------ |
| 93 | |