diff options
Diffstat (limited to 'tmk_core/tool/mbed/mbed-sdk/libraries/tests/net/helloworld/multicast_send/main.cpp')
-rw-r--r-- | tmk_core/tool/mbed/mbed-sdk/libraries/tests/net/helloworld/multicast_send/main.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tmk_core/tool/mbed/mbed-sdk/libraries/tests/net/helloworld/multicast_send/main.cpp b/tmk_core/tool/mbed/mbed-sdk/libraries/tests/net/helloworld/multicast_send/main.cpp new file mode 100644 index 0000000000..df41c6d80a --- /dev/null +++ b/tmk_core/tool/mbed/mbed-sdk/libraries/tests/net/helloworld/multicast_send/main.cpp @@ -0,0 +1,24 @@ +#include "mbed.h" +#include "EthernetInterface.h" + +const char* MCAST_GRP = "224.1.1.1"; +const int MCAST_PORT = 5007; + +int main() { + EthernetInterface eth; + eth.init(); //Use DHCP + eth.connect(); + + UDPSocket sock; + sock.init(); + + Endpoint multicast_group; + multicast_group.set_address(MCAST_GRP, MCAST_PORT); + + char out_buffer[] = "very important data"; + while (true) { + printf("Multicast to group: %s\n", MCAST_GRP); + sock.sendTo(multicast_group, out_buffer, sizeof(out_buffer)); + Thread::wait(1000); + } +} |