Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: HTTPClient_HelloWorld_WIZ550io NTPClient_HelloWorld_WIZ550io
Fork of WIZ820ioInterface by
Diff: Socket/Endpoint.cpp
- Revision:
- 5:fb15c35d1e28
- Parent:
- 1:fb4494783863
--- 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;
}
