You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2019/02/28 02:40:48 UTC

[GitHub] jovany-wang commented on a change in pull request #98: [ISSUE #42] Fixed this issue that cann't set namesrv with hostname

jovany-wang commented on a change in pull request #98: [ISSUE #42] Fixed this issue that cann't set namesrv with hostname
URL: https://github.com/apache/rocketmq-client-cpp/pull/98#discussion_r261027318
 
 

 ##########
 File path: src/transport/TcpTransport.cpp
 ##########
 @@ -65,6 +65,41 @@ tcpConnectStatus TcpTransport::connect(const string &strServerURL,
   memset(&sin, 0, sizeof(sin));
   sin.sin_family = AF_INET;
   sin.sin_addr.s_addr = inet_addr(hostName.c_str());
+ 
+  if (sin.sin_addr.s_addr == INADDR_NONE) {
+	  struct evutil_addrinfo hints;
+	  struct evutil_addrinfo *answer = NULL;
+	  /* Build the hints to tell getaddrinfo how to act. */
+	  memset(&hints, 0, sizeof(hints));
+	  hints.ai_family = AF_UNSPEC; /* v4 or v6 is fine. */			   
+	  /* Look up the hostname. */
+	  int err = evutil_getaddrinfo(hostName.c_str(), NULL, &hints, &answer);
+	  if (err != 0) {
+		  string info = "Error while resolving " + hostName + ":" + evutil_gai_strerror(err);
 
 Review comment:
   ```c++
   std::string errorMessage = "Failed to resolve  host name(" + hostName + "): " + evutil_gai_strerror(err);
   ```
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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