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.
Fork of Controle_ventilo_ethernet_v1_2_4 by
main.cpp
- Committer:
- Brutus
- Date:
- 2016-10-31
- Revision:
- 0:5ca563ae05db
- Child:
- 1:179393386b47
File content as of revision 0:5ca563ae05db:
#include "mbed.h"
#include "EthernetInterface.h"
#include "Ethernet.h"
/*#include "TCPSocket.h"
#include "TCPServer.h"*/
#include "SocketAddress.h"
#include "Socket.h"
#include "UDPSocket.h"
#define ECHO_SERVER_PORT 7
int main (void) {
EthernetInterface eth;
eth.connect();
printf("\nServer IP Address is %s\n", eth.get_ip_address());
UDPSocket server;
server.bind(ECHO_SERVER_PORT);
SocketAddress client;
char buffer[256];
while (true) {
printf("\nWaiting for UDP packet...\n");
int n = server.recvfrom(client, buffer, sizeof(buffer));
buffer[n] = '\0';
printf("Received packet from: %s\n", client.get_ip_address());
printf("Packet contents : '%s'\n",buffer);
printf("Sending Packet back to Client\n");
server.sendto(client, buffer, n);
}
}
