| 605 | |
| 606 | public: |
| 607 | ACTOR static Future<Reference<IUDPSocket>> connect(boost::asio::io_service* io_service, |
| 608 | Optional<NetworkAddress> toAddress, |
| 609 | bool isV6) { |
| 610 | state Reference<UDPSocket> self(new UDPSocket(*io_service, toAddress, isV6)); |
| 611 | ASSERT(!toAddress.present() || toAddress.get().ip.isV6() == isV6); |
| 612 | if (!toAddress.present()) { |
| 613 | return self; |
| 614 | } |
| 615 | try { |
| 616 | if (toAddress.present()) { |
| 617 | auto to = udpEndpoint(toAddress.get()); |
| 618 | BindPromise p("N2_UDPConnectError", self->id); |
| 619 | Future<Void> onConnected = p.getFuture(); |
| 620 | self->socket.async_connect(to, std::move(p)); |
| 621 | |
| 622 | wait(onConnected); |
| 623 | } |
| 624 | self->init(); |
| 625 | return self; |
| 626 | } catch (...) { |
| 627 | self->closeSocket(); |
| 628 | throw; |
| 629 | } |
| 630 | } |
| 631 | |
| 632 | void close() override { closeSocket(); } |
| 633 |
nothing calls this directly
no test coverage detected