Example program for the BSDInterface

Dependencies:   BSDInterface NetworkSocketAPI

Fork of HelloLWIPInterface by NetworkSocketAPI

Files at this revision

API Documentation at this revision

Comitter:
sarahmarshy
Date:
Wed Aug 05 21:59:08 2015 +0000
Parent:
20:4cb9ef3b0cc9
Child:
23:9ca7d3d1a2df
Commit message:
DNS example in main

Changed in this revision

DnsQuery.lib Show annotated file Show diff for this revision Revisions of this file
ESP8266Interface.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DnsQuery.lib	Wed Aug 05 21:59:08 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/sarahmarshy/code/DnsQuery/#12d08f0f20cf
--- a/ESP8266Interface.lib	Sun Jul 26 21:55:02 2015 +0000
+++ b/ESP8266Interface.lib	Wed Aug 05 21:59:08 2015 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/teams/NetworkSocketAPI/code/ESP8266Interface/#37504440f296
+https://developer.mbed.org/teams/NetworkSocketAPI/code/ESP8266Interface/#eaeecaaae611
--- a/main.cpp	Sun Jul 26 21:55:02 2015 +0000
+++ b/main.cpp	Wed Aug 05 21:59:08 2015 +0000
@@ -29,23 +29,27 @@
     printf("NetworkSocketAPI Example\r\n");
 
     wifi.init();
-    wifi.connect("Buffalo-G-1280", "13808136");
+    wifi.connect("iotlab", "42F67YxLX4AawRdcj");
     
     char* ip;
     ip = wifi.getIPAddress();
     printf("IP Address is: %s\n", (ip) ? ip : "No IP");
+    char host_ip[50];
+    wifi.getHostByName("google.com",host_ip);
+    printf("Google.com resolved to: %s\n",host_ip);
     
-    SocketInterface* mySocket = wifi.allocateSocket(SOCK_UDP);
+
+    SocketInterface* mySocket = wifi.allocateSocket(SOCK_TCP);
     char recieved[100];
     int recv_amnt = 0;
     
-    mySocket->setAddressPort("192.168.13.6", 7);
+    //Sending and receiving from echo server 
+    mySocket->setAddressPort("192.168.13.8", 7);
     mySocket->open();
     mySocket->send("Hello",5, 10000);
     recieved[5] = 0;
     recv_amnt = mySocket->recv(recieved, 5, 10000);
     printf("Recieved: %d, %s\n",recv_amnt, recieved);
-    
     mySocket->close();
     wifi.disconnect();
 }