ap
Dependencies: DnsQuery
Dependents: WizFi310_TCP_Echo_Server_Example
Fork of NetworkSocketAPI by
Diff: SocketAddress.cpp
- Revision:
- 80:9c6673c93082
- Parent:
- 79:43a7e8c0d6cc
- Child:
- 86:7ca9776b9cc0
--- a/SocketAddress.cpp Tue Apr 05 10:40:34 2016 -0500 +++ b/SocketAddress.cpp Tue Apr 05 12:02:56 2016 -0500 @@ -15,8 +15,20 @@ */ #include "SocketAddress.h" +#include "NetworkInterface.h" #include <string.h> +SocketAddress::SocketAddress(NetworkInterface *iface, const char *host, uint16_t port) +{ + int err = iface->gethostbyname(host, _ip_address); + set_port(port); + + if (err) { + _ip_address[0] = '\0'; + _port = 0; + } +} + SocketAddress::SocketAddress(const char *addr, uint16_t port) { set_ip_address(addr); @@ -42,6 +54,9 @@ const char *SocketAddress::get_ip_address() const { + if (!_ip_address[0]) { + return 0; + } return _ip_address; }