| 225 | #endif |
| 226 | > |
| 227 | send_result_t |
| 228 | send_multipart(socket_ref s, Range &&msgs, send_flags flags = send_flags::none) |
| 229 | { |
| 230 | using std::begin; |
| 231 | using std::end; |
| 232 | auto it = begin(msgs); |
| 233 | const auto end_it = end(msgs); |
| 234 | size_t msg_count = 0; |
| 235 | while (it != end_it) { |
| 236 | const auto next = std::next(it); |
| 237 | const auto msg_flags = |
| 238 | flags | (next == end_it ? send_flags::none : send_flags::sndmore); |
| 239 | if (!s.send(*it, msg_flags)) { |
| 240 | // zmq ensures atomic delivery of messages |
| 241 | assert(it == begin(msgs)); |
| 242 | return {}; |
| 243 | } |
| 244 | ++msg_count; |
| 245 | it = next; |
| 246 | } |
| 247 | return msg_count; |
| 248 | } |
| 249 | |
| 250 | /* Encode a multipart message. |
| 251 | |