Simple code for comunication via TCP between the mbed and PC.
Dependencies: EthernetInterface SimpleSocket mbed-rtos mbed
Fork of SimpleSocketExamples by
examples/udpreceiver.cpp
- Committer:
- yamaguch
- Date:
- 2013-02-04
- Revision:
- 0:6dc3cfd058c6
File content as of revision 0:6dc3cfd058c6:
#include "SimpleSocket.h" void udpreceiver() { DatagramSocket datagram(7777); datagram.setTimeout(1.0); Endpoint buddy; while (true) { if (datagram.receive(buddy) > 0) { char *ip = buddy.get_address(); int port = buddy.get_port(); char buf[80] = {}; int len = datagram.read(buf, sizeof(buf) - 1); printf("received from %s:%d %s", ip, port, buf); } } }