| 10 | } |
| 11 | |
| 12 | bool open(const char* addr, const char* iface, int port) { |
| 13 | unsigned oflags = acl::OPEN_FLAG_REUSEPORT; |
| 14 | if (loopback_) { |
| 15 | oflags |= acl::OPEN_FLAG_MULTICAST_LOOP; |
| 16 | } |
| 17 | |
| 18 | if (ss_.bind_multicast(addr, iface, port, -1, oflags)) { |
| 19 | printf("Open ok, addr=%s, iface=%s, port=%d\r\n", |
| 20 | addr, iface, port); |
| 21 | return true; |
| 22 | } |
| 23 | |
| 24 | printf("Bind error=%s, addr=%s, iface=%s, port=%d\r\n", |
| 25 | acl::last_serror(), addr, iface, port); |
| 26 | return false; |
| 27 | } |
| 28 | |
| 29 | protected: |
| 30 | acl::socket_stream ss_; |