Skip to content

Commit 16c5020

Browse files
author
hewei.it
committed
feat: Resolve DNS to get the latest IP address when reconnect (#798)
1 parent ada9e70 commit 16c5020

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

evpp/TcpClient.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,13 @@ class TcpClientEventLoopTmpl {
105105

106106
int startConnect() {
107107
if (channel == NULL || channel->isClosed()) {
108-
int connfd = createsocket(&remote_addr.sa);
108+
int connfd = -1;
109+
if (reconn_setting && reconn_setting->cur_retry_cnt > 1) {
110+
// Resolve DNS to get the latest IP address
111+
connfd = createsocket(remote_port, remote_host.c_str());
112+
} else {
113+
connfd = createsocket(&remote_addr.sa);
114+
}
109115
if (connfd < 0) {
110116
hloge("createsocket %s:%d return %d!\n", remote_host.c_str(), remote_port, connfd);
111117
return connfd;

0 commit comments

Comments
 (0)