Reputation: 67
I have 2 different machine example is 192.168.11.115 and 192.168.11.114 Machine 192.168.11.114 will send video stream to multicast address 239.0.0.1 and port 1234 And I want machine 192.168.11.115 can't read from above multicast address and only 192.168.11.114 can read it
Im using libuv and c++
This is code I using to send video stream to multicast address
struct sockaddr_in send_addr;
uv_ip4_addr("239.0.0.1", 1234, &send_addr);
uv_buf_t buf = uv_buf_init((char*)message, len);
uv_udp_send_t* send_req = new uv_udp_send_t;
uv_udp_send(send_req, &_udpSend, &buf, 1, reinterpret_cast<const struct sockaddr*>(&send_addr), on_send);
And this is I init uv_udp_t
status = uv_udp_init(_loop, &_udpSend);
struct sockaddr_in send_addr;
uv_ip4_addr("0.0.0.0", 1111, &send_addr);
uv_udp_bind(&_udpSend, (const struct sockaddr*)&send_addr, UV_UDP_REUSEADDR);
// uv_udp_set_multicast_interface(&_udpSend, "192.168.11.114");
// uv_udp_set_membership(&_udpSend, "239.0.0.1", "192.168.11.114", UV_JOIN_GROUP);
uv_udp_recv_start(&_udpSend, on_alloc, on_recv);
I have try set multicast interface but its not work. And I know I can send unicast but the player not support play unicast video stream
Upvotes: 0
Views: 72
Reputation: 67
I found solution that add multicast interface with local ip to make multicast only work with local ip
uv_udp_set_multicast_interface(&_udpSend, "127.0.0.1");
uv_udp_set_membership(&_udpSend, "239.0.0.1", "127.0.0.1", UV_JOIN_GROUP);
Upvotes: 0