Skip to content

Commit c7c4b3a

Browse files
committed
EthernetClass hostByName added
1 parent 39103da commit c7c4b3a

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/Ethernet.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "Ethernet.h"
2323
#include "utility/w5100.h"
2424
#include "Dhcp.h"
25+
#include "Dns.h"
2526

2627
IPAddress EthernetClass::_dnsServerAddress;
2728
DhcpClass* EthernetClass::_dhcp = NULL;
@@ -224,6 +225,13 @@ void EthernetClass::setRetransmissionCount(uint8_t num)
224225
SPI.endTransaction();
225226
}
226227

228+
int EthernetClass::hostByName(const char* hostname, IPAddress& result)
229+
{
230+
int ret = 0;
231+
DNSClient dns;
232+
dns.begin(_dnsServerAddress);
233+
return dns.getHostByName(hostname, result);
234+
}
227235

228236

229237

src/Ethernet.h

+2
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ class EthernetClass {
105105
void setRetransmissionTimeout(uint16_t milliseconds);
106106
void setRetransmissionCount(uint8_t num);
107107

108+
int hostByName(const char* hostname, IPAddress& result);
109+
108110
friend class EthernetClient;
109111
friend class EthernetServer;
110112
friend class EthernetUDP;

0 commit comments

Comments
 (0)