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: EthernetInterface WebSocketClient mbed-rtos mbed
Fork of UDPSocket_HelloWorld by
Diff: main.cpp
- Revision:
- 1:8e1d4987eb90
- Parent:
- 0:d85529a216ea
- Child:
- 6:25aad2d88749
--- a/main.cpp Tue Jun 26 14:43:18 2012 +0000
+++ b/main.cpp Tue Jun 26 15:37:24 2012 +0000
@@ -1,32 +1,32 @@
-#include "mbed.h"
-#include "EthernetInterface.h"
-
-int main()
-{
- EthernetInterface eth;
- eth.init(); //Use DHCP
-
- eth.connect();
-
- UDPSocket sock;
- sock.bind(0); //Use a random port
-
- const char daytime_cmd[] = "plop"; //Does not matter
- sock.sendTo((std::uint8_t*)daytime_cmd, sizeof(daytime_cmd) - 1, "utcnist.colorado.edu", 37, 3000);
-
- char* inHost;
- int inPort;
- char in_buf[4];
- int ret = sock.receiveFrom((std::uint8_t*)in_buf, 4, &inHost, &inPort, 3000);
-
- std::uint32_t timeRes = ntohl( *((std::uint32_t*)in_buf));
-
- printf("Received %d bytes from server %s on port %d: %u seconds since 1/01/1900 00:00 GMT\n", ret, inHost, inPort, timeRes);
-
- sock.close();
-
- eth.disconnect();
-
- while(1) {
- }
-}
+#include "mbed.h"
+#include "EthernetInterface.h"
+
+int main()
+{
+ EthernetInterface eth;
+ eth.init(); //Use DHCP
+
+ eth.connect();
+
+ UDPSocket sock;
+ sock.bind(0); //Use a random port
+
+ char daytime_cmd[] = "plop"; //Does not matter
+ sock.sendTo(daytime_cmd, sizeof(daytime_cmd) - 1, "utcnist.colorado.edu", 37, 3000);
+
+ char* inHost;
+ int inPort;
+ char in_buf[4];
+ int ret = sock.receiveFrom((char*)in_buf, 4, &inHost, &inPort, 3000);
+
+ unsigned int timeRes = ntohl( *((unsigned int*)in_buf));
+
+ printf("Received %d bytes from server %s on port %d: %u seconds since 1/01/1900 00:00 GMT\n", ret, inHost, inPort, timeRes);
+
+ sock.close();
+
+ eth.disconnect();
+
+ while(1) {
+ }
+}
