Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions src/cli/tls_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,12 +397,8 @@ class TLS_Client final : public Command {
throw CLI_Error("getaddrinfo failed for " + host);
}

socket_type fd = 0;
bool success = false;

for(const addrinfo* rp = res.get(); rp != nullptr; rp = rp->ai_next) {
fd = ::socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);

const socket_type fd = ::socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
if(fd == invalid_socket()) {
continue;
}
Expand All @@ -416,17 +412,11 @@ class TLS_Client final : public Command {
::close(fd);
continue;
}

success = true;
break;
}

if(!success) {
// no address succeeded
throw CLI_Error("Connecting to host failed");
return fd;
}

return fd;
// no address succeeded
throw CLI_Error("Connecting to host failed");
}

static void dgram_socket_write(int sockfd, const uint8_t buf[], size_t length) {
Expand Down
Loading