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: EthernetNetIf SimpleSocket 1.0 mbed
udpreceiver.cpp@34:a108bcc26b69, 2011-11-04 (annotated)
- Committer:
- yamaguch
- Date:
- Fri Nov 04 06:04:36 2011 +0000
- Revision:
- 34:a108bcc26b69
- Parent:
- 33:39d9cdf99de8
removed Serial mon,;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| yamaguch |
33:39d9cdf99de8 | 1 | #include "EthernetNetIf.h" |
| yamaguch |
33:39d9cdf99de8 | 2 | #include "SimpleSocket.h" |
| yamaguch |
33:39d9cdf99de8 | 3 | |
| yamaguch |
33:39d9cdf99de8 | 4 | void udpreceiver() { |
| yamaguch |
33:39d9cdf99de8 | 5 | EthernetNetIf eth; |
| yamaguch |
33:39d9cdf99de8 | 6 | eth.setup(); |
| yamaguch |
34:a108bcc26b69 | 7 | |
| yamaguch |
33:39d9cdf99de8 | 8 | DatagramSocket datagram(7777); |
| yamaguch |
33:39d9cdf99de8 | 9 | |
| yamaguch |
33:39d9cdf99de8 | 10 | Host buddy; |
| yamaguch |
33:39d9cdf99de8 | 11 | while (true) { |
| yamaguch |
34:a108bcc26b69 | 12 | if (datagram.receive(&buddy, 1) > 0) { |
| yamaguch |
33:39d9cdf99de8 | 13 | IpAddr ip = buddy.getIp(); |
| yamaguch |
34:a108bcc26b69 | 14 | int port = buddy.getPort(); |
| yamaguch |
33:39d9cdf99de8 | 15 | char buf[80] = {}; |
| yamaguch |
33:39d9cdf99de8 | 16 | int len = datagram.read(buf, sizeof(buf) - 1); |
| yamaguch |
34:a108bcc26b69 | 17 | printf("received from %d.%d.%d.%d:%d %s", ip[0],ip[1], ip[2], ip[3], port, buf); |
| yamaguch |
33:39d9cdf99de8 | 18 | } |
| yamaguch |
33:39d9cdf99de8 | 19 | } |
| yamaguch |
33:39d9cdf99de8 | 20 | } |