Skip to content

Commit

Permalink
EthernetClass hostByName added
Browse files Browse the repository at this point in the history
  • Loading branch information
JAndrassy committed Oct 7, 2023
1 parent 39103da commit c7c4b3a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Ethernet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "Ethernet.h"
#include "utility/w5100.h"
#include "Dhcp.h"
#include "Dns.h"

IPAddress EthernetClass::_dnsServerAddress;
DhcpClass* EthernetClass::_dhcp = NULL;
Expand Down Expand Up @@ -224,6 +225,13 @@ void EthernetClass::setRetransmissionCount(uint8_t num)
SPI.endTransaction();
}

int EthernetClass::hostByName(const char* hostname, IPAddress& result)
{
int ret = 0;
DNSClient dns;
dns.begin(_dnsServerAddress);
return dns.getHostByName(hostname, result);
}



Expand Down
2 changes: 2 additions & 0 deletions src/Ethernet.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ class EthernetClass {
void setRetransmissionTimeout(uint16_t milliseconds);
void setRetransmissionCount(uint8_t num);

int hostByName(const char* hostname, IPAddress& result);

friend class EthernetClient;
friend class EthernetServer;
friend class EthernetUDP;
Expand Down

0 comments on commit c7c4b3a

Please sign in to comment.