Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.

Commit baeb3b8

Browse files
author
Me No Dev
committed
lets actually fail if dns failed to find ip of the host
1 parent 107827f commit baeb3b8

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/ESPAsyncTCP.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,13 +323,21 @@ int8_t AsyncClient::_poll(tcp_pcb* pcb){
323323
return ERR_OK;
324324
}
325325

326+
void AsyncClient::_dns_found(ip_addr_t *ipaddr){
327+
if(ipaddr){
328+
connect(IPAddress(ipaddr->addr), _connect_port);
329+
} else {
330+
if(_error_cb)
331+
_error_cb(_error_cb_arg, this, -55);
332+
if(_discard_cb)
333+
_discard_cb(_discard_cb_arg, this);
334+
}
335+
}
336+
326337
// lWIP Callbacks
327338

328339
void AsyncClient::_s_dns_found(const char *name, ip_addr_t *ipaddr, void *arg){
329-
if(ipaddr){
330-
AsyncClient* c = reinterpret_cast<AsyncClient*>(arg);
331-
c->connect(IPAddress(ipaddr->addr), c->_connect_port);
332-
}
340+
reinterpret_cast<AsyncClient*>(arg)->_dns_found(ipaddr);
333341
}
334342

335343
int8_t AsyncClient::_s_poll(void *arg, struct tcp_pcb *tpcb) {
@@ -533,6 +541,7 @@ const char * AsyncClient::errorToString(int8_t error){
533541
case -13: return "Address in use";
534542
case -14: return "Low-level netif error";
535543
case -15: return "Already connected";
544+
case -55: return "DNS failed";
536545
default: return "UNKNOWN";
537546
}
538547
}

src/ESPAsyncTCP.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ class AsyncClient {
7878
int8_t _poll(tcp_pcb* pcb);
7979
int8_t _sent(tcp_pcb* pcb, uint16_t len);
8080
int8_t _recv(tcp_pcb* pcb, pbuf* pb, int8_t err);
81+
void _dns_found(ip_addr_t *ipaddr);
8182
static int8_t _s_poll(void *arg, struct tcp_pcb *tpcb);
8283
static int8_t _s_recv(void *arg, struct tcp_pcb *tpcb, struct pbuf *pb, int8_t err);
8384
static void _s_error(void *arg, int8_t err);

0 commit comments

Comments
 (0)