Validation
Dependencies: EthernetInterface WebSocketClient mbed-rtos mbed
Fork of UDPSocket_HelloWorld by
main.cpp
- Committer:
- emilmont
- Date:
- 2012-07-26
- Revision:
- 6:25aad2d88749
- Parent:
- 1:8e1d4987eb90
- Child:
- 7:dedf5dde9798
File content as of revision 6:25aad2d88749:
#include "mbed.h" #include "EthernetInterface.h" int main() { EthernetInterface eth; eth.init(); //Use DHCP eth.connect(); UDPSocket sock; sock.init(); char out_buffer[] = "plop"; // Does not matter UDPPacket out_packet(out_buffer, sizeof(out_buffer)); out_packet.set_address("utcnist.colorado.edu", 37); sock.sendTo(out_packet); char in_buffer[4]; UDPPacket in_packet(in_buffer, sizeof(in_buffer)); int n = sock.receiveFrom(in_packet); unsigned int timeRes = ntohl( *((unsigned int*)in_buffer)); printf("Received %d bytes from server %s on port %d: %u seconds since 1/01/1900 00:00 GMT\n", n, in_packet.get_address(), in_packet.get_port(), timeRes); sock.close(); eth.disconnect(); while(1) {} }