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: SDFileSystem WIZnetInterface mbed
Fork of UDPEchoServer by
main.cpp
- Committer:
- Kojto
- Date:
- 2014-05-14
- Revision:
- 5:76845960c8a2
- Parent:
- 2:6b1012d93eb2
- Child:
- 6:bd7f46b6fa23
File content as of revision 5:76845960c8a2:
#include "mbed.h"
#include "EthernetInterface.h"
#define ECHO_SERVER_PORT 7
int main (void) {
EthernetInterface eth;
eth.init(); //Use DHCP
eth.connect();
printf("IP Address is %s\n", eth.getIPAddress());
UDPSocket server;
server.bind(ECHO_SERVER_PORT);
Endpoint client;
char buffer[256];
while (true) {
printf("\nWait for packet...\n");
int n = server.receiveFrom(client, buffer, sizeof(buffer));
printf("Received packet from: %s\n", client.get_address());
server.sendTo(client, buffer, n);
}
}
