szaszm commented on a change in pull request #713: WIP: MINIFICPP-1119 
MINIFICPP-1154 unify win/posix sockets + fix bugs
URL: https://github.com/apache/nifi-minifi-cpp/pull/713#discussion_r380341790
 
 

 ##########
 File path: libminifi/src/io/ClientSocket.cpp
 ##########
 @@ -51,50 +50,57 @@ namespace nifi {
 namespace minifi {
 namespace io {
 
-Socket::Socket(const std::shared_ptr<SocketContext> &context, const 
std::string &hostname, const uint16_t port, const uint16_t listeners = -1)
-    : requested_hostname_(hostname),
+static std::string get_last_err_str() noexcept {
+#ifdef WIN32
+  const auto error_code = WSAGetLastError();
+#else
+  const auto error_code = errno;
+#endif /* WIN32 */
+  return std::system_category().message(error_code);
+}
+
+static bool valid_sock_fd(SocketDescriptor fd) {
+#ifdef WIN32
+  return fd != INVALID_SOCKET && fd >= 0;
+#else
+  return fd >= 0;
+#endif /* WIN32 */
+}
+
+Socket::Socket(const std::shared_ptr<SocketContext>& /*context*/, std::string 
hostname, const uint16_t port, const uint16_t listeners)
+    : requested_hostname_(std::move(hostname)),
       port_(port),
-      socket_file_descriptor_(-1),
-      socket_max_(0),
-      total_written_(0),
-      total_read_(0),
-      is_loopback_only_(false),
       listeners_(listeners),
-      canonical_hostname_(""),
-      nonBlocking_(false),
       logger_(logging::LoggerFactory<Socket>::getLogger()) {
   FD_ZERO(&total_list_);
   FD_ZERO(&read_fds_);
   initialize_socket();
 }
 
-Socket::Socket(const std::shared_ptr<SocketContext> &context, const 
std::string &hostname, const uint16_t port)
-    : Socket(context, hostname, port, 0) {
-  initialize_socket();
+Socket::Socket(const std::shared_ptr<SocketContext>& context, std::string 
hostname, const uint16_t port)
+    : Socket(context, std::move(hostname), port, 0) {
 }
 
-Socket::Socket(const Socket &&other)
+Socket::Socket(Socket &&other) noexcept
 
 Review comment:
   updated

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to