You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2020/02/17 19:35:20 UTC

[GitHub] [nifi-minifi-cpp] szaszm commented on a change in pull request #713: WIP: MINIFICPP-1119 MINIFICPP-1154 unify win/posix sockets + fix bugs

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:
users@infra.apache.org


With regards,
Apache Git Services