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.
main.cpp
- Committer:
- emilmont
- Date:
- 2013-03-01
- Revision:
- 0:28ba970b3e23
File content as of revision 0:28ba970b3e23:
#include "mbed.h"
#include "EthernetInterface.h"
const int BROADCAST_PORT = 58083;
int main() {
EthernetInterface eth;
eth.init(); //Use DHCP
eth.connect();
UDPSocket socket;
socket.bind(BROADCAST_PORT);
socket.set_broadcasting();
Endpoint broadcaster;
char buffer[256];
while (true) {
printf("\nWait for packet...\n");
int n = socket.receiveFrom(broadcaster, buffer, sizeof(buffer));
buffer[n] = '\0';
printf("Packet from \"%s\": %s\n", broadcaster.get_address(), buffer);
}
}