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
Diff: udpreceiver.cpp
- Revision:
- 34:a108bcc26b69
- Parent:
- 33:39d9cdf99de8
diff -r 39d9cdf99de8 -r a108bcc26b69 udpreceiver.cpp
--- a/udpreceiver.cpp Wed Nov 02 12:16:51 2011 +0000
+++ b/udpreceiver.cpp Fri Nov 04 06:04:36 2011 +0000
@@ -4,15 +4,17 @@
void udpreceiver() {
EthernetNetIf eth;
eth.setup();
+
DatagramSocket datagram(7777);
Host buddy;
while (true) {
- if (datagram.receive(&buddy, 4) > 0) {
+ if (datagram.receive(&buddy, 1) > 0) {
IpAddr ip = buddy.getIp();
+ int port = buddy.getPort();
char buf[80] = {};
int len = datagram.read(buf, sizeof(buf) - 1);
- printf("received from %d.%d.%d.%d: %s", ip[0],ip[1], ip[2], ip[3], buf);
+ printf("received from %d.%d.%d.%d:%d %s", ip[0],ip[1], ip[2], ip[3], port, buf);
}
}
}
\ No newline at end of file