Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EthernetInterface mbed-rtos mbed
Fork of MulticastReceive by
main.cpp
00001 #include "mbed.h" 00002 #include "EthernetInterface.h" 00003 00004 const char* MCAST_GRP = "224.1.1.1"; 00005 const int MCAST_PORT = 5007; 00006 00007 int main() { 00008 EthernetInterface eth; 00009 eth.init(); //Use DHCP 00010 eth.connect(); 00011 00012 UDPSocket server; 00013 server.bind(MCAST_PORT); 00014 if (server.join_multicast_group(MCAST_GRP) != 0) { 00015 printf("Error joining the multicast group\n"); 00016 while (true) {} 00017 } 00018 00019 Endpoint client; 00020 char buffer[256]; 00021 while (true) { 00022 printf("\nWait for packet...\n"); 00023 int n = server.receiveFrom(client, buffer, sizeof(buffer)); 00024 00025 printf("Packet from \"%s\": %s\n", client.get_address(), buffer); 00026 } 00027 }
Generated on Tue Jul 12 2022 21:36:09 by
