Custom and bugfix

Dependents:   HTTPClient_HelloWorld_WIZ820io NTPClient_HelloWorld_WIZ820io TinyHTTPServer_WIZ820io

Fork of WIZ820ioInterface by Norimasa Okamoto

Revision:
5:fb15c35d1e28
Parent:
1:fb4494783863
diff -r 0bcec6272784 -r fb15c35d1e28 Socket/Endpoint.cpp
--- a/Socket/Endpoint.cpp	Thu Dec 20 15:08:58 2012 +0000
+++ b/Socket/Endpoint.cpp	Tue Aug 27 12:50:11 2013 +0000
@@ -17,14 +17,8 @@
  */
 #include "Socket/Socket.h"
 #include "Socket/Endpoint.h"
-#include <cstring>
-
-using std::memset;
 
 Endpoint::Endpoint()  {
-    wifly = Wifly::getInstance();
-    if (wifly == NULL)
-        error("Endpoint constructor error: no wifly instance available!\r\n");
     reset_address();
 }
 Endpoint::~Endpoint() {}
@@ -36,7 +30,15 @@
 
 int Endpoint::set_address(const char* host, const int port) {
     //Resolve DNS address or populate hard-coded IP address
-    wifly->gethostbyname(host, _ipAddress);
+    WIZ820io* eth = WIZ820io::getInstance();
+    if (eth == NULL) {
+        return -1;
+    }
+    uint32_t addr;
+    if (!eth->gethostbyname(host, &addr)) {
+        return -1;
+    }
+    snprintf(_ipAddress, sizeof(_ipAddress), "%d.%d.%d.%d", (addr>>24)&0xff, (addr>>16)&0xff, (addr>>8)&0xff, addr&0xff);
     _port = port;
     return 0;
 }