MCPcopy Create free account
hub / github.com/bcndev/bytecoin / send

Method send

src/platform/Network.cpp:1080–1108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1078}
1079UDPMulticast::~UDPMulticast() { impl->close(); }
1080void UDPMulticast::send(const std::string &addr, uint16_t port, const void *data, size_t size) {
1081 try {
1082 // Multicast will not work on loopback
1083 {
1084 // boost::asio::ip::address local_ad = boost::asio::ip::address::from_string("127.0.0.1");
1085 // boost::asio::ip::udp::endpoint local_ep(local_ad, port);
1086 // boost::asio::ip::udp::socket local_socket(EventLoop::current()->io(), local_ep.protocol());
1087 // local_socket.send_to(boost::asio::buffer(data, size), local_ep);
1088 } {
1089 boost::asio::ip::address ad = boost::asio::ip::address::from_string(addr);
1090 boost::asio::ip::udp::endpoint ep(ad, port);
1091 boost::asio::ip::udp::socket socket(EventLoop::current()->io(), ep.protocol());
1092
1093 // socket.set_option(boost::asio::ip::multicast::enable_loopback(true));
1094 // socket.set_option(boost::asio::ip::multicast::hops(2));
1095 auto local_addresses = TCPAcceptor::local_addresses(true, false);
1096 for (const auto &la : local_addresses) {
1097 boost::asio::ip::address_v4 local_interface = boost::asio::ip::address_v4::from_string(la);
1098 socket.set_option(boost::asio::ip::multicast::outbound_interface(local_interface));
1099 socket.send_to(boost::asio::buffer(data, size), ep);
1100 }
1101 if (local_addresses.empty()) // Send on default gateway
1102 socket.send_to(boost::asio::buffer(data, size), ep);
1103 }
1104 } catch (const std::exception &) {
1105 // std::cout << "UDPMulticast::send exception to addr=" << addr << " port=" << port
1106 // << " error=" << common::what(ex) << std::endl;
1107 }
1108}
1109
1110#endif // #if TARGET_OS_IPHONE
1111

Callers

nothing calls this directly

Calls 1

emptyMethod · 0.45

Tested by

no test coverage detected