AXISCPP-1069 Use inet_addr first if hostname begins with number to avoid gethostbyname timeout
diff --git a/src/transport/axis3/HTTPChannel/HTTPChannel.cpp b/src/transport/axis3/HTTPChannel/HTTPChannel.cpp
index b3000a0..e97d717 100644
--- a/src/transport/axis3/HTTPChannel/HTTPChannel.cpp
+++ b/src/transport/axis3/HTTPChannel/HTTPChannel.cpp
@@ -16,6 +16,8 @@
 // !!! Must be first thing in file !!!
 #include "../../../platforms/PlatformAutoSense.hpp"
 
+#include <ctype.h>
+
 #include "HTTPChannel.hpp"
 
 #include "../../../common/AxisTrace.h"
@@ -592,18 +594,12 @@
     svAddr.sin_family = AF_INET;
     svAddr.sin_port = htons( port);
 
-    // Probably this is the host-name of the server we are connecting to...
-#ifdef __OS400__
-    if( (pHostEntry = gethostbyname( (char *)host)))
-#else
-    if( (pHostEntry = gethostbyname( host)))
-#endif
+    // Host names must start with a character (RFC1035)...so if it starts with a number, let us first
+    // assume it is dotted decimal format...and if it fails, we will then assume it is a host name.
+    // We do this so that we avoid long DNS timeouts if we use gethostbyname() first.
+    svAddr.sin_addr.s_addr = -1;
+    if (isdigit(host[0]))
     {
-        svAddr.sin_addr.s_addr = ((struct in_addr *) pHostEntry->h_addr)->s_addr;
-    }
-    else
-    {
-        // No this is the IP address
 #ifdef __OS400__
         svAddr.sin_addr.s_addr = inet_addr( (char *)host);
 #else
@@ -611,6 +607,16 @@
 #endif
     }
 
+    if (svAddr.sin_addr.s_addr == -1)
+    {
+#ifdef __OS400__
+        if( (pHostEntry = gethostbyname( (char *)host)))
+#else
+        if( (pHostEntry = gethostbyname( host)))
+#endif
+            svAddr.sin_addr.s_addr = ((struct in_addr *) pHostEntry->h_addr)->s_addr;
+    }
+
     // Attempt to connect to the remote server.
     if( connect( m_Sock, (struct sockaddr *) &svAddr, sizeof (svAddr)) == SOCKET_ERROR)
     {
@@ -810,4 +816,4 @@
 {
     AxisTrace::setLogFilter(filters);
     AxisTrace::startTrace(logFilePath, false);
-}
\ No newline at end of file
+}
diff --git a/src/transport/axis3/HTTPSSLChannel/HTTPSSLChannel.cpp b/src/transport/axis3/HTTPSSLChannel/HTTPSSLChannel.cpp
index c52d5c8..03419da 100644
--- a/src/transport/axis3/HTTPSSLChannel/HTTPSSLChannel.cpp
+++ b/src/transport/axis3/HTTPSSLChannel/HTTPSSLChannel.cpp
@@ -16,6 +16,8 @@
 // !!! Must be first thing in file !!!
 #include "../../../platforms/PlatformAutoSense.hpp"
 
+#include <ctype.h>
+
 #include "HTTPSSLChannel.hpp"
 
 #include "../../../common/AxisTrace.h"
@@ -706,16 +708,15 @@
     svAddr.sin_family = AF_INET;
     svAddr.sin_port = htons( port);
 
-    // Probably this is the host-name of the server we are connecting to...
-    if( (pHostEntry = gethostbyname( host)))
-    {
-        svAddr.sin_addr.s_addr = ((struct in_addr *) pHostEntry->h_addr)->s_addr;
-    }
-    else
-    {
-        // No this is the IP address
+    // Host names must start with a character (RFC1035)...so if it starts with a number, let us first
+    // assume it is dotted decimal format...and if it fails, we will then assume it is a host name.
+    // We do this so that we avoid long DNS timeouts if we use gethostbyname() first.
+    svAddr.sin_addr.s_addr = -1;
+    if (isdigit(host[0]))
         svAddr.sin_addr.s_addr = inet_addr( host);
-    }
+
+    if ((svAddr.sin_addr.s_addr == -1) && (pHostEntry = gethostbyname( host)))
+        svAddr.sin_addr.s_addr = ((struct in_addr *) pHostEntry->h_addr)->s_addr;
 
     // Attempt to connect to the remote server.
     if( connect( m_Sock, (struct sockaddr *) &svAddr, sizeof (svAddr)) == SOCKET_ERROR)