Simple code for comunication via TCP between the mbed and PC.
Dependencies: EthernetInterface SimpleSocket mbed-rtos mbed
Fork of SimpleSocketExamples by
examples/multicast.cpp
- Committer:
- yamaguch
- Date:
- 2013-02-04
- Revision:
- 0:6dc3cfd058c6
File content as of revision 0:6dc3cfd058c6:
#include "SimpleSocket.h" void multicast() { Endpoint multicast; multicast.set_address("239.192.1.100", 50000); DatagramSocket datagram(multicast); while (true) { Endpoint host; datagram.setTimeout(1 + (rand() % 5) / 3.0); if (datagram.receive(host) > 0) { int value; datagram.scanf("%d", &value); char *ip = host.get_address(); printf("received from %s:%d %d\n", ip, host.get_port(), value); } else { char* message = "12345!"; datagram.printf(message); datagram.send(multicast); printf("sent: %s\n", message); wait(1); } } }