Move to SocketAddress in gethostbyname

pull/2216/head^2
Christopher Haster 2016-03-13 16:55:34 -05:00
parent 3f08f3957c
commit bd8cbf0fcb
3 changed files with 12 additions and 7 deletions

View File

@ -17,7 +17,14 @@
#include "DnsQuery.h"
#include "mbed.h"
int NetworkInterface::gethostbyname(const char *name, char *dest)
int NetworkInterface::gethostbyname(SocketAddress *address, const char *name)
{
return dnsQuery(this, name, dest);
char buffer[NSAPI_IP_SIZE];
int err = dnsQuery(this, name, buffer);
if (err) {
return err;
}
address->set_ip_address(buffer);
return 0;
}

View File

@ -87,11 +87,11 @@ public:
}
/** Looks up the specified host's IP address
* @param address Destination for the host SocketAddress
* @param name Hostname to lookup
* @param dest Destination for IP address, must have space for SocketAddress::IP_SIZE
* @return 0 on success, negative on failure
*/
virtual int gethostbyname(const char *name, char *dest);
virtual int gethostbyname(SocketAddress *address, const char *name);
protected:
friend class Socket;

View File

@ -98,10 +98,8 @@ SocketAddress::SocketAddress(NetworkInterface *iface, const char *host, uint16_t
address_to_ipv4(_ip_bytes, host);
} else {
// DNS lookup
char addr[NSAPI_IP_SIZE];
int err = iface->gethostbyname(host, addr);
int err = iface->gethostbyname(this, host);
if (!err) {
set_ip_address(addr);
set_port(port);
} else {
_ip_version = NSAPI_IPv4;