UDP broadcast metro apps.
-
Tuesday, July 31, 2012 9:09 AM
Hi guys,
Is there a way to send a udp broadcast message ?
It seems sending to 255.255.255.255 via the DatagramSocket class simply does nothing...Kind regs,
Roman Pfneudl CEO - vertex4 entertainment ltd.
All Replies
-
Tuesday, July 31, 2012 9:51 AM
Oops, seems to be my fault.
Sending to 255.255.255.255 works as designed.Here my extremly crappy code - example for future reference:
String ^strHost = ref new String("255.255.255.255"); String ^strPort = ref new String("27960"); IAsyncOperation<IOutputStream^> ^op = _socket->GetOutputStreamAsync(ref new HostName(strHost), strPort);
op->Completed = ref new AsyncOperationCompletedHandler<IOutputStream^> ( [] (IAsyncOperation<IOutputStream^> ^op, Windows::Foundation::AsyncStatus status) { // CHECK op->ErrorCode.Value HERE IOutputStream ^ostream = op->GetResults();
DataWriter ^writer = ref new DataWriter(ostream); auto data = ref new Platform::Array<unsigned char>(7); ::memcpy(data->Data, "iAmHere", 7); writer->WriteBytes (data); writer->StoreAsync (); } );
Kind Regs
Roman Pfneudl CEO - vertex4 entertainment ltd.
- Marked As Answer by v4corg Tuesday, July 31, 2012 9:52 AM
-
Wednesday, August 01, 2012 8:07 AMModerator
Thanks for sharing the solution.
Best regards,
JesseJesse Jiang [MSFT]
MSDN Community Support | Feedback to us
-
Tuesday, December 18, 2012 1:28 AM
Hi,
Are you able to get UDP broadcast working through WIFI? Thanks.
-
Tuesday, December 18, 2012 7:52 AMHi there. Yes indeed - seems to make no difference.
Roman Pfneudl CEO - vertex4 entertainment ltd.
-
Tuesday, December 18, 2012 6:21 PM
Thanks.
My computer connects both to Ethernet and WIFI. It looks like it only send the broadcast packets to the default connection (Ethernet). After the Ethernet connection is disabled, another device in the same WIFI network is able to receive the broadcast packets.


