Trying an app for Windows Phone 8.1 and wondering how should I use DatagramSocket to send data to a multicast address. If I try to use ConnectAsync(HostName host) with some multicast address, ie. 239.0.0.1, I get a message "ConnectAcync() does not support multicast address". How can I connect to multicast address and how can I send data to it?
1 Answers
0
votes
You must use DatagramSocket.JoinMulticastGroup()
, see here: https://msdn.microsoft.com/en-us/library/windows/apps/windows.networking.sockets.datagramsocket.joinmulticastgroup.aspx
UPDATE:
To just send a UDP message try:
IOutputStream outputStream = await datagramSocket.GetOutputStreamAsync(
hostName,
serviceName);
IBuffer buffer = Encoding.UTF8.GetBytes("hello").AsBuffer();
uint bytesWritten = await outputStream.WriteAsync(buffer);