szaszm 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_r376018290
########## 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: Changed to `< 0` since `0` is a valid file descriptor. ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services