on start
{
const dword kVlanId = 1;
dword socket;
long result;
ip_Endpoint [FF03::cafe]:1234 IPv6_MulticastEp;
// open a socket
socket = udpOpen(ip_Endpoint([0::0]:0));
if(socket == ~0)
{
write("<%BASE_FILE_NAME%>: udpOpen failed (%d)", ipGetLastError());
}
// set the outgoing interface for multicast messages
result = ipSetMulticastInterface(socket, ipGetAdapter(%CHANNEL%, kVlanId));
if(result != 0)
{
write("<%BASE_FILE_NAME%>: ipSetMulticastInterface failed (result: %d, last socket error: %d)", result, ipGetLastSocketError(socket));
}
// for ipv6 it is necessary to also set the scope Id
// to the same interface
IPv6_MulticastEp.Address.ScopeID = ipGetAdapter(%CHANNEL%, kVlanId);
// send the multicast message
result = udpSendTo(socket, IPv6_MulticastEp, "Hello", 5);
if(result != 0)
{
write("<%BASE_FILE_NAME%>: udpSendTo failed (result: %d, last socket error: %d)", result, ipGetLastSocketError(socket));
}
udpClose(socket);
}