![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Non-blocking example of the LWIPInterface
Dependencies: LWIPInterface NetworkSocketAPI mbed-rtos mbed
Non-blocking example for the NetworkSocketAPI. Attempts to get the device's public facing IP address from ifcfg.me using the Happy Eyeballs algorithm to fetch an IPv4 or IPv6 address.
Diff: main.cpp
- Revision:
- 59:14d6716bc772
- Parent:
- 58:7033f5893210
- Child:
- 65:826ec2bbec51
--- a/main.cpp Tue Apr 05 15:32:00 2016 -0500 +++ b/main.cpp Tue Apr 05 23:40:09 2016 +0000 @@ -25,7 +25,6 @@ } LWIPInterface eth; -TCPSocket socket(ð); int main() { @@ -39,7 +38,11 @@ const char *mac = eth.get_mac_address(); printf("IP Address is: %s\r\n", (ip) ? ip : "No IP"); printf("MAC Address is: %s\r\n", (mac) ? mac : "No MAC"); + + SocketAddress addr(ð, "time-a.nist.gov", 37); + printf("time-a.nist.gov resolved to: %s\r\n", addr.get_ip_address()); + TCPSocket socket(ð); socket.connect("time-a.nist.gov", 37); char recieved[100] = {0};