<p>
Got it to work. the ones in bold and big are the ones I edited in the code.
</p>
<pre>
<font color=green>GSocket</font>* GetTheSocketReady(<font color=blue>const char</font>* ipaddress, <font color=blue>const int</font> portNumber, <font color=blue>const char</font>* interfaceIp)
{
<font color=green>GSocketAddress</font> *bind_addr;
<font color=green>GInetAddress</font> *bind_iaddr;
<font color=green>GSocketFamily</font> family;
<font color=green>guint16</font> port = portNumber;
<font color=green>GError</font> *err = NULL;
<font color=green>gint</font> val = 0;
<font color=blue>const</font> <font color=green>guint8</font> *native_addr;
<b><font size=5 color=blue>struct</font> <font size=5 color=green>ip_mreq</font> <font size=5>mc_req;</font></b>
GInetSocketAddress *bAddr;
guint16 bPort;
bind_iaddr = g_inet_address_new_from_string(ipaddress);
bind_addr = g_inet_socket_address_new(bind_iaddr, port);
family = g_socket_address_get_family(G_SOCKET_ADDRESS(bind_addr));
GSocket * socketUDP = g_socket_new(family, G_SOCKET_TYPE_DATAGRAM, G_SOCKET_PROTOCOL_UDP, &err);
if (socketUDP == <font color=purple>NULL</font>)
{
printf("Could not create socket: %s", err->message);
g_object_unref(bind_addr);
<font color=blue>goto</font> Error;
}
if (!g_socket_bind(socketUDP, g_inet_socket_address_new(g_inet_address_new_from_string(interfaceIp), port), <font color=blue>TRUE</font>, &err))
{
printf("Failed to bind socket: %s", err->message);
<font color=blue>goto</font> Error;
}
g_socket_set_multicast_loopback(socketUDP, TRUE);
if (g_socket_get_option(socketUDP, SOL_SOCKET, SO_RCVBUF, &val,
NULL)) {
std::cout << "\r\nReceived\r\n";
}
else {
goto Error;
}
g_socket_set_broadcast(socketUDP, TRUE);
native_addr = g_inet_address_to_bytes(bind_iaddr);
memset(&mc_req, 0, <font color=blue>sizeof</font>(mc_req));
memcpy(&mc_req.imr_multiaddr, native_addr, sizeof(<font color=blue>struct</font> in_addr));
<font size=4><b>inet_pton(AF_INET, interfaceIp, &mc_req.imr_interface);</b></font>
<font size=4><b>inet_pton(AF_INET, ipaddress, &mc_req.imr_multiaddr);</b></font>
if (setsockopt(g_socket_get_fd(socketUDP), IPPROTO_IP, IP_ADD_MEMBERSHIP,
(char*)&mc_req, sizeof(mc_req)))
{
printf("\r\nYeah\r\n");
}
End:
{
g_object_unref(bind_iaddr);
<font color=blue>return</font> socketUDP;
}
Error:
{
g_object_unref(bind_iaddr);
<font color=green>return</font> <font color=purple>NULL</font>;
}
}
</pre>
<div class="signature" style="margin-top:1em;color:#666666;font-size:11px;">
------------------------------
<br/>Gstreamer 1.14.3
<br/>------------------------------
<br/>Windows
</div>
<br/><hr align="left" width="300" />
Sent from the <a href="http://gstreamer-devel.966125.n4.nabble.com/">GStreamer-devel mailing list archive</a> at Nabble.com.<br/>