From issues-return-91395-archive-asf-public=cust-asf.ponee.io@nifi.apache.org Mon Feb 3 16:10:26 2020 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id ACE4718067F for ; Mon, 3 Feb 2020 17:10:25 +0100 (CET) Received: (qmail 83894 invoked by uid 500); 3 Feb 2020 16:10:24 -0000 Mailing-List: contact issues-help@nifi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@nifi.apache.org Delivered-To: mailing list issues@nifi.apache.org Received: (qmail 83694 invoked by uid 99); 3 Feb 2020 16:10:24 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Feb 2020 16:10:24 +0000 From: GitBox To: issues@nifi.apache.org Subject: [GitHub] [nifi-minifi-cpp] arpadboda commented on a change in pull request #713: MINIFICPP-1119 unify win/posix sockets + clean up issues Message-ID: <158074622462.17340.17176792378524363023.gitbox@gitbox.apache.org> References: In-Reply-To: Date: Mon, 03 Feb 2020 16:10:24 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit arpadboda commented on a change in pull request #713: MINIFICPP-1119 unify win/posix sockets + clean up issues URL: https://github.com/apache/nifi-minifi-cpp/pull/713#discussion_r374190470 ########## File path: libminifi/src/io/ClientSocket.cpp ########## @@ -207,12 +209,31 @@ int8_t Socket::createConnection(const addrinfo *p, in_addr_t &addr) { } else { logger_->log_error("Unknown error"); } - -#endif closeStream(); socket_file_descriptor_ = -1; return -1; } +#else + auto *sa_loc = (struct sockaddr_in*) p->ai_addr; + sa_loc->sin_family = AF_INET; + sa_loc->sin_port = htons(port_); + // use any address if you are connecting to the local machine for testing + // otherwise we must use the requested hostname + if (IsNullOrEmpty(requested_hostname_) || requested_hostname_ == "localhost") { + if (is_loopback_only_) { + sa_loc->sin_addr.s_addr = htonl(INADDR_LOOPBACK); + } else { + sa_loc->sin_addr.s_addr = htonl(INADDR_ANY); + } + } else { + sa_loc->sin_addr.s_addr = addr; + } + if (connect(socket_file_descriptor_, p->ai_addr, p->ai_addrlen) == -1) { Review comment: I would prefer <= 0 or != 0 checks. In case someone changes the code by introducing a new error this silently gets broken. I know it's not completely new code, more like a wish to do it nicely as we touch. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org With regards, Apache Git Services