Skip to content

Commit

Permalink
EthernetClass hostByName added
Browse files Browse the repository at this point in the history
  • Loading branch information
JAndrassy committed Jan 5, 2024
1 parent 39103da commit 74b52db
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 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,12 @@ void EthernetClass::setRetransmissionCount(uint8_t num)
SPI.endTransaction();
}

int EthernetClass::hostByName(const char* hostname, IPAddress& result)
{
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 74b52db

Please sign in to comment.