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:
- 15:e48b3c6558b1
- Parent:
- 14:c47437f5dae8
- Child:
- 16:bb0a5b830dc5
diff -r c47437f5dae8 -r e48b3c6558b1 main.cpp --- a/main.cpp Wed Jul 15 23:23:14 2015 +0000 +++ b/main.cpp Thu Jul 16 05:20:12 2015 +0000 @@ -16,7 +16,6 @@ #include "mbed.h" #include "WiFiRadioInterface.h" -#include <map> DigitalOut myled(LED1); @@ -37,7 +36,7 @@ printf("MAC: %s\r\n", wifi.getMACAddress()); SocketInterface* myTCPSocket = wifi.allocateSocket(SOCK_TCP); - SocketInterface* myUDPSocket = wifi.allocateSocket(SOCK_TCP); + SocketInterface* myUDPSocket = wifi.allocateSocket(SOCK_UDP); myTCPSocket->setAddress(myTCPSocket->getHostByName("www.google.com")); myTCPSocket->setAddress("216.58.192.46");