You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-commits@axis.apache.org by na...@apache.org on 2012/05/11 07:13:01 UTC

svn commit: r1337028 - in /axis/axis1/c/trunk: include/axis/ include/axis/client/ src/cbindings/client/ src/engine/client/ src/platforms/aix/ src/platforms/hp-ux/ src/platforms/os400/ src/platforms/unix/ src/platforms/windows/ src/transport/ src/transp...

Author: nadiramra
Date: Fri May 11 05:13:01 2012
New Revision: 1337028

URL: http://svn.apache.org/viewvc?rev=1337028&view=rev
Log:
AXISCPP-526 Add ability to specify connect timeout

Modified:
    axis/axis1/c/trunk/include/axis/GDefine.h
    axis/axis1/c/trunk/include/axis/GDefine.hpp
    axis/axis1/c/trunk/include/axis/client/Stub.h
    axis/axis1/c/trunk/include/axis/client/Stub.hpp
    axis/axis1/c/trunk/src/cbindings/client/StubC.cpp
    axis/axis1/c/trunk/src/engine/client/Stub.cpp
    axis/axis1/c/trunk/src/platforms/aix/PlatformSpecificAIX.hpp
    axis/axis1/c/trunk/src/platforms/hp-ux/PlatformSpecificHP-UX.hpp
    axis/axis1/c/trunk/src/platforms/os400/PlatformSpecificOS400.hpp
    axis/axis1/c/trunk/src/platforms/unix/PlatformSpecificUnix.hpp
    axis/axis1/c/trunk/src/platforms/windows/PlatformSpecificWindows.hpp
    axis/axis1/c/trunk/src/transport/SOAPTransport.h
    axis/axis1/c/trunk/src/transport/axis3/HTTPChannel/HTTPChannel.cpp
    axis/axis1/c/trunk/src/transport/axis3/HTTPChannel/HTTPChannel.hpp
    axis/axis1/c/trunk/src/transport/axis3/HTTPSSLChannel/HTTPSSLChannel.cpp
    axis/axis1/c/trunk/src/transport/axis3/HTTPSSLChannel/HTTPSSLChannel.hpp
    axis/axis1/c/trunk/src/transport/axis3/HTTPTransport.cpp
    axis/axis1/c/trunk/src/transport/axis3/HTTPTransport.hpp
    axis/axis1/c/trunk/src/transport/axis3/IChannel.hpp

Modified: axis/axis1/c/trunk/include/axis/GDefine.h
URL: http://svn.apache.org/viewvc/axis/axis1/c/trunk/include/axis/GDefine.h?rev=1337028&r1=1337027&r2=1337028&view=diff
==============================================================================
--- axis/axis1/c/trunk/include/axis/GDefine.h (original)
+++ axis/axis1/c/trunk/include/axis/GDefine.h Fri May 11 05:13:01 2012
@@ -183,11 +183,22 @@ typedef enum 
     AXISC_ENABLE_AUTOMATIC_REDIRECT,
 
     /**
-     * Maximum number of automatic redirects to follow.  Property should be a numeric string.
+     * Maximum number of automatic redirects to follow.  Property should be a string representing a numeric value.
      * Default is 1. If "0" is specified, it will be as if AXISC_ENABLE_AUTOMATIC_REDIRECT is set to
      * false.
      */
-    AXISC_MAX_AUTOMATIC_REDIRECT
+    AXISC_MAX_AUTOMATIC_REDIRECT,
+
+    /**
+     * I/O timeout in seconds.  Property should be a string representing a numeric value.
+     */
+    AXISC_IO_TIMEOUT,
+
+    /**
+     * Connect timeout in seconds.  Property should be a string representing a numeric value.
+     */
+    AXISC_CONNECT_TIMEOUT
+
 } AXISC_TRANSPORT_INFORMATION_TYPE;
 
 #define AXISC_SOAPACTIONHEADER "SOAPAction"

Modified: axis/axis1/c/trunk/include/axis/GDefine.hpp
URL: http://svn.apache.org/viewvc/axis/axis1/c/trunk/include/axis/GDefine.hpp?rev=1337028&r1=1337027&r2=1337028&view=diff
==============================================================================
--- axis/axis1/c/trunk/include/axis/GDefine.hpp (original)
+++ axis/axis1/c/trunk/include/axis/GDefine.hpp Fri May 11 05:13:01 2012
@@ -202,11 +202,21 @@ typedef enum 
     ENABLE_AUTOMATIC_REDIRECT,
 
     /**
-     * Maximum number of automatic redirects to follow.  Property should be a numeric string.
+     * Maximum number of automatic redirects to follow.  Property should be a string representing a numeric value.
      * Default is 1. If "0" is specified, it will be as if ENABLE_AUTOMATIC_REDIRECT is set to
      * false.
      */
-    MAX_AUTOMATIC_REDIRECT
+    MAX_AUTOMATIC_REDIRECT,
+
+    /**
+     * I/O timeout in seconds.  Property should be a string representing a numeric value.
+     */
+    IO_TIMEOUT,
+
+    /**
+     * Connect timeout in seconds.  Property should be a string representing a numeric value.
+     */
+    CONNECT_TIMEOUT
 
 } AXIS_TRANSPORT_INFORMATION_TYPE;
 

Modified: axis/axis1/c/trunk/include/axis/client/Stub.h
URL: http://svn.apache.org/viewvc/axis/axis1/c/trunk/include/axis/client/Stub.h?rev=1337028&r1=1337027&r2=1337028&view=diff
==============================================================================
--- axis/axis1/c/trunk/include/axis/client/Stub.h (original)
+++ axis/axis1/c/trunk/include/axis/client/Stub.h Fri May 11 05:13:01 2012
@@ -434,6 +434,17 @@ AXISC_STORAGE_CLASS_INFO
 void axiscStubSetTransportTimeout(AXISCHANDLE stub, long lSeconds);
 
 /**
+ * Set transport connect timeout.
+ *
+ * @param lSeconds Timeout in seconds.
+ *                 If lSeconds is 0, then the transport will assume no
+ *                 timeout. Hence you want to reset a timeout already set
+ *                 use 0.
+ */
+AXISC_STORAGE_CLASS_INFO
+void axiscStubSetTransportConnectTimeout(AXISCHANDLE stub, long lSeconds);
+
+/**
  * Get the status of the stub to see any error situation
  */
 AXISC_STORAGE_CLASS_INFO

Modified: axis/axis1/c/trunk/include/axis/client/Stub.hpp
URL: http://svn.apache.org/viewvc/axis/axis1/c/trunk/include/axis/client/Stub.hpp?rev=1337028&r1=1337027&r2=1337028&view=diff
==============================================================================
--- axis/axis1/c/trunk/include/axis/client/Stub.hpp (original)
+++ axis/axis1/c/trunk/include/axis/client/Stub.hpp Fri May 11 05:13:01 2012
@@ -568,6 +568,16 @@ class STORAGE_CLASS_INFO Stub
     */
     void setTransportTimeout(long lSeconds);
     
+    /**
+      * Set transport connect timeout.
+      *
+      * @param lSeconds Timeout in seconds.
+      *                 If lSeconds is 0, then the transport will assume no
+      *                 timeout. Hence you want to reset a timeout already set
+      *                 use 0.
+      */
+     void setTransportConnectTimeout(long lSeconds);
+
   /**
     * Get the status of the stub to see any error situation
     */

Modified: axis/axis1/c/trunk/src/cbindings/client/StubC.cpp
URL: http://svn.apache.org/viewvc/axis/axis1/c/trunk/src/cbindings/client/StubC.cpp?rev=1337028&r1=1337027&r2=1337028&view=diff
==============================================================================
--- axis/axis1/c/trunk/src/cbindings/client/StubC.cpp (original)
+++ axis/axis1/c/trunk/src/cbindings/client/StubC.cpp Fri May 11 05:13:01 2012
@@ -32,6 +32,7 @@
 
 #include "StubC.h"
 
+#include "../../transport/SOAPTransport.h"
 #include "../../common/AxisTrace.h"
 
 AXIS_CPP_NAMESPACE_USE
@@ -536,6 +537,31 @@ void axiscStubSetTransportTimeout(AXISCH
     }
 }
 
+
+AXISC_STORAGE_CLASS_INFO
+void axiscStubSetTransportConnectTimeout(AXISCHANDLE stub,
+                                         long lSeconds)
+{
+    StubC *s = (StubC*)stub;
+
+    try
+    {
+        Call *c = s->getCallStubC();
+        SOAPTransport *t = c->getTransport();
+        if (t)
+            t->setConnectTimeout (lSeconds);
+    }
+    catch ( AxisException& e  )
+    {
+
+        processException(s, e.getExceptionCode(), e.what());
+    }
+    catch ( ... )
+    {
+        processException(s, -1, "Unrecognized exception thrown.");
+    }
+}
+
 AXISC_STORAGE_CLASS_INFO 
 int axiscStubGetStatus(AXISCHANDLE stub) 
 {

Modified: axis/axis1/c/trunk/src/engine/client/Stub.cpp
URL: http://svn.apache.org/viewvc/axis/axis1/c/trunk/src/engine/client/Stub.cpp?rev=1337028&r1=1337027&r2=1337028&view=diff
==============================================================================
--- axis/axis1/c/trunk/src/engine/client/Stub.cpp (original)
+++ axis/axis1/c/trunk/src/engine/client/Stub.cpp Fri May 11 05:13:01 2012
@@ -484,6 +484,17 @@ Stub::setTransportTimeout (long lSeconds
     logExit()
 }
 
+void
+Stub::setTransportConnectTimeout (long lSeconds)
+{
+      logEntryEngine("Stub::setTransportConnectTimeout")
+
+    if (m_pTransport)
+        m_pTransport->setConnectTimeout (lSeconds);
+
+    logExit()
+}
+
 int
 Stub::getStatus ()
 {

Modified: axis/axis1/c/trunk/src/platforms/aix/PlatformSpecificAIX.hpp
URL: http://svn.apache.org/viewvc/axis/axis1/c/trunk/src/platforms/aix/PlatformSpecificAIX.hpp?rev=1337028&r1=1337027&r2=1337028&view=diff
==============================================================================
--- axis/axis1/c/trunk/src/platforms/aix/PlatformSpecificAIX.hpp (original)
+++ axis/axis1/c/trunk/src/platforms/aix/PlatformSpecificAIX.hpp Fri May 11 05:13:01 2012
@@ -101,6 +101,22 @@
 #include <sys/timeb.h>
 #include <pthread.h>
 #include <unistd.h>
+#include <fcntl.h>      // for nonblocking
+
+#define PLATFORM_SET_SOCKET_BLOCKING(x)           \
+{                                                 \
+    int fcntlArg = fcntl(x, F_GETFL, NULL);       \
+    fcntlArg &= (~O_NONBLOCK);                    \
+    fcntl(x, F_SETFL, fcntlArg);                  \
+}
+
+#define PLATFORM_SET_SOCKET_NONBLOCKING(x)        \
+{                                                 \
+    int fcntlArg = fcntl(x, F_GETFL, NULL);       \
+    fcntlArg |= O_NONBLOCK;                       \
+    fcntl(x, F_SETFL, fcntlArg);                  \
+}
+
 #define PLATFORM_SLEEP(x) sleep(x)
 
 

Modified: axis/axis1/c/trunk/src/platforms/hp-ux/PlatformSpecificHP-UX.hpp
URL: http://svn.apache.org/viewvc/axis/axis1/c/trunk/src/platforms/hp-ux/PlatformSpecificHP-UX.hpp?rev=1337028&r1=1337027&r2=1337028&view=diff
==============================================================================
--- axis/axis1/c/trunk/src/platforms/hp-ux/PlatformSpecificHP-UX.hpp (original)
+++ axis/axis1/c/trunk/src/platforms/hp-ux/PlatformSpecificHP-UX.hpp Fri May 11 05:13:01 2012
@@ -100,6 +100,22 @@
 #include <unistd.h>
 #include <pthread.h>
 #include <errno.h>
+#include <fcntl.h>      // for nonblocking
+
+#define PLATFORM_SET_SOCKET_BLOCKING(x)           \
+{                                                 \
+    int fcntlArg = fcntl(x, F_GETFL, NULL);       \
+    fcntlArg &= (~O_NONBLOCK);                    \
+    fcntl(x, F_SETFL, fcntlArg);                  \
+}
+
+#define PLATFORM_SET_SOCKET_NONBLOCKING(x)        \
+{                                                 \
+    int fcntlArg = fcntl(x, F_GETFL, NULL);       \
+    fcntlArg |= O_NONBLOCK;                       \
+    fcntl(x, F_SETFL, fcntlArg);                  \
+}
+
 #define PLATFORM_SLEEP(x) sleep(x)
 
 /**

Modified: axis/axis1/c/trunk/src/platforms/os400/PlatformSpecificOS400.hpp
URL: http://svn.apache.org/viewvc/axis/axis1/c/trunk/src/platforms/os400/PlatformSpecificOS400.hpp?rev=1337028&r1=1337027&r2=1337028&view=diff
==============================================================================
--- axis/axis1/c/trunk/src/platforms/os400/PlatformSpecificOS400.hpp (original)
+++ axis/axis1/c/trunk/src/platforms/os400/PlatformSpecificOS400.hpp Fri May 11 05:13:01 2012
@@ -30,6 +30,7 @@
 #include <unistd.h>     // access()
 #include <string>  
 
+
 #define DIR_SEPARATOR   '/'
 #define DIR_SEPARATOR_S "/"
 
@@ -109,6 +110,22 @@ extern char PLATFORM_XML_ENTITY_REFERENC
 #include <pthread.h> 
 #include <unistd.h>
 #include <errno.h>
+#include <fcntl.h>      // for nonblocking
+
+#define PLATFORM_SET_SOCKET_BLOCKING(x)           \
+{                                                 \
+    int fcntlArg = fcntl(x, F_GETFL, NULL);       \
+    fcntlArg &= (~O_NONBLOCK);                    \
+    fcntl(x, F_SETFL, fcntlArg);                  \
+}
+
+#define PLATFORM_SET_SOCKET_NONBLOCKING(x)        \
+{                                                 \
+    int fcntlArg = fcntl(x, F_GETFL, NULL);       \
+    fcntlArg |= O_NONBLOCK;                       \
+    fcntl(x, F_SETFL, fcntlArg);                  \
+}
+
 #define PLATFORM_SLEEP(x) sleep(x)
 
 

Modified: axis/axis1/c/trunk/src/platforms/unix/PlatformSpecificUnix.hpp
URL: http://svn.apache.org/viewvc/axis/axis1/c/trunk/src/platforms/unix/PlatformSpecificUnix.hpp?rev=1337028&r1=1337027&r2=1337028&view=diff
==============================================================================
--- axis/axis1/c/trunk/src/platforms/unix/PlatformSpecificUnix.hpp (original)
+++ axis/axis1/c/trunk/src/platforms/unix/PlatformSpecificUnix.hpp Fri May 11 05:13:01 2012
@@ -94,6 +94,22 @@
 #include <sys/timeb.h>
 #include <unistd.h>
 #include <errno.h>
+#include <fcntl.h>            // for nonblocking
+
+#define PLATFORM_SET_SOCKET_BLOCKING(x)           \
+{                                                 \
+    int fcntlArg = fcntl(x, F_GETFL, NULL);       \
+    fcntlArg &= (~O_NONBLOCK);                    \
+    fcntl(x, F_SETFL, fcntlArg);                  \
+}
+
+#define PLATFORM_SET_SOCKET_NONBLOCKING(x)        \
+{                                                 \
+    int fcntlArg = fcntl(x, F_GETFL, NULL);       \
+    fcntlArg |= O_NONBLOCK;                       \
+    fcntl(x, F_SETFL, fcntlArg);                  \
+}
+
 #define PLATFORM_SLEEP(x) sleep(x)
 
 /**

Modified: axis/axis1/c/trunk/src/platforms/windows/PlatformSpecificWindows.hpp
URL: http://svn.apache.org/viewvc/axis/axis1/c/trunk/src/platforms/windows/PlatformSpecificWindows.hpp?rev=1337028&r1=1337027&r2=1337028&view=diff
==============================================================================
--- axis/axis1/c/trunk/src/platforms/windows/PlatformSpecificWindows.hpp (original)
+++ axis/axis1/c/trunk/src/platforms/windows/PlatformSpecificWindows.hpp Fri May 11 05:13:01 2012
@@ -127,6 +127,18 @@
 // =============================================================
 // Miscellaneous
 // =============================================================
+#define PLATFORM_SET_SOCKET_BLOCKING(x)           \
+{                                                 \
+    u_long iMode = 0;                             \
+    ioctlsocket(x, FIONBIO, &iMode);              \
+}
+
+#define PLATFORM_SET_SOCKET_NONBLOCKING(x)        \
+{                                                 \
+    u_long iMode = 1;                             \
+    ioctlsocket(x, FIONBIO, &iMode);              \
+}
+
 #define PLATFORM_SLEEP(x) Sleep(x)
 
 /**

Modified: axis/axis1/c/trunk/src/transport/SOAPTransport.h
URL: http://svn.apache.org/viewvc/axis/axis1/c/trunk/src/transport/SOAPTransport.h?rev=1337028&r1=1337027&r2=1337028&view=diff
==============================================================================
--- axis/axis1/c/trunk/src/transport/SOAPTransport.h (original)
+++ axis/axis1/c/trunk/src/transport/SOAPTransport.h Fri May 11 05:13:01 2012
@@ -14,19 +14,6 @@
  *   See the License for the specific language governing permissions and
  *   limitations under the License.
  *
- * @author Susantha Kumara (skumara@virtusa.com, susantha@opensource.lk)
- * @author Samisa Abeysinghe (sabeysinghe@virtusa.com)
- *
- */
-
-/*
- * Revision 1.1  2004/05/31 samisa
- * Added setProxy
- */
-
-/*
- * Revision 1.2  2004/06/08 samisa
- * Added setTimeout
  */
 
 #if !defined(AXIS_SOAPTRANSPORT_H__OF_AXIS_INCLUDED_)
@@ -162,7 +149,7 @@ public:
      *
      * @brief Gets a part of or full SOAP message.
      * @pre   Transport connection should have been established by calling
-     *        Openconnection of the SOAPTransport's implementaion.
+     *        Openconnection of the SOAPTransport's implementation.
      * @param pcBuffer The character buffer provided by the caller to be
      *        filled by the transport layer. The size of the buffer is given
      *        by the value of second parameter piRetSize. The transport layer
@@ -420,6 +407,13 @@ public:
     */
     virtual void setTimeout(long lSeconds) = 0;
     
+    /**
+      * Set transport connect timeout.
+      *
+      * @param lSeconds Timeout in seconds
+      */
+    virtual void setConnectTimeout(long lSeconds) = 0;
+
   /**    
     * Iterator initiatior for transport property keys
     *

Modified: axis/axis1/c/trunk/src/transport/axis3/HTTPChannel/HTTPChannel.cpp
URL: http://svn.apache.org/viewvc/axis/axis1/c/trunk/src/transport/axis3/HTTPChannel/HTTPChannel.cpp?rev=1337028&r1=1337027&r2=1337028&view=diff
==============================================================================
--- axis/axis1/c/trunk/src/transport/axis3/HTTPChannel/HTTPChannel.cpp (original)
+++ axis/axis1/c/trunk/src/transport/axis3/HTTPChannel/HTTPChannel.cpp Fri May 11 05:13:01 2012
@@ -46,7 +46,8 @@ HTTPChannel()
 #else
     m_lTimeoutSeconds = 0;
 #endif
-
+    m_lConnectTimeoutSeconds = 0;
+    
     bNoExceptionOnForceClose = false;
 
     if( !StartSockets())
@@ -140,22 +141,15 @@ open()
 {
     logEntryTransport("HTTPChannel::open")
 
-    bool    bSuccess = (bool) AXIS_FAIL;
-
     CloseChannel();
 
     m_LastError = "No Errors";
 
-    if( (bSuccess = OpenChannel()) != AXIS_SUCCESS)
-    {
-        logThrowExceptionWithData("HTTPTransportException - SERVER_TRANSPORT_SOCKET_CONNECT_ERROR", m_LastError.c_str())
-
-        throw HTTPTransportException( SERVER_TRANSPORT_SOCKET_CONNECT_ERROR, m_LastError.c_str());
-    }
+    OpenChannel();
 
     logExit()
     
-    return bSuccess;
+    return AXIS_SUCCESS;
 }
 
 /**
@@ -196,16 +190,16 @@ GetLastErrorMsg()
 /**
  * HTTPChannel::readBytes()
  *
- * This method attempts to read a message from the curently open channel.  If
+ * This method attempts to read a message from the currently open channel.  If
  * there is no currently open channel, then the method throws an exception.  If
- * there is an open channel, but nothing to recieve, then then method will
- * timeout and throw an exception.  If the mesage is interrupted or the
+ * there is an open channel, but nothing to receive, then then method will
+ * timeout and throw an exception.  If the message is interrupted or the
  * transmitting side closes then an exception is thrown.
  *
  * @param character pointer containing an array of character that can be filled
- * by the reieved message (NB: The maximum message length is BUF_SIZE).
+ * by the received message (NB: The maximum message length is BUF_SIZE).
  * @return character pointer pointing to the array of character containing the
- * recieved message.
+ * received message.
  */
 
 int HTTPChannel::
@@ -226,9 +220,9 @@ readBytes(char *buf, int bufLen)
     int     iBufSize = bufLen - 10;
 
     // If timeout set then wait for maximum amount of time for data
-    if( m_lTimeoutSeconds)
+    if( m_lTimeoutSeconds > 0)
     {
-        int iTimeoutStatus = applyTimeout();
+        int iTimeoutStatus = applyTimeout(m_lTimeoutSeconds, true);
 
         // Handle timeout outcome
         if( iTimeoutStatus < 0)
@@ -349,6 +343,24 @@ setTimeout( long lSeconds)
 }
 
 /**
+ * HTTPChannel::setConnectTimeout( const long lSeconds)
+ *
+ * Set the connect timeout (in seconds)
+ *
+ * @param long containing timeout value in seconds
+ */
+
+void HTTPChannel::
+setConnectTimeout( long lSeconds)
+{
+    logEntryTransport("HTTPChannel::setConnectTimeout")
+
+    m_lConnectTimeoutSeconds = lSeconds;
+    
+    logExit()
+}
+
+/**
  * HTTPChannel::setSocket( unsigned int uiNewSocket)
  *
  * This is used by the server side to change the server socket.
@@ -456,10 +468,8 @@ OpenChannel()
 {
     logEntryTransport("HTTPChannel::OpenChannel")
 
-    // This method is common to all channel implementations
-    bool    bSuccess = (bool) AXIS_FAIL;
+    int     rc = 0;
 
-    // Create the Client (Rx) side first.
 #ifdef IPV6
     struct addrinfo     aiHints;
     struct addrinfo *   paiAddrInfo;
@@ -506,17 +516,10 @@ OpenChannel()
         if( connect( m_Sock, paiAddrInfo->ai_addr, paiAddrInfo->ai_addrlen) < 0)
         {
             // This must be done first thing to get proper error. Generate full message.
-            ReportError();
-            char buffer[100];
-            sprintf(buffer, "%d", m_URL.getPort());
-            string fullMessage = "Failed to open connection to server at host " +
-                                 string(m_URL.getHostName()) + 
-                                 " and port " +  string(buffer) + ".\n" + m_LastError;
-
+            ReportError(true);
             CloseChannel();
+
             freeaddrinfo( paiAddrInfo0);
-            
-            m_LastError = fullMessage;
 
             logThrowExceptionWithData("HTTPTransportException - CLIENT_TRANSPORT_OPEN_CONNECTION_FAILED", m_LastError.c_str())
 
@@ -538,47 +541,20 @@ OpenChannel()
 
         throw HTTPTransportException( SERVER_TRANSPORT_SOCKET_CREATE_ERROR, m_LastError.c_str());
     }
-
-    bSuccess = AXIS_SUCCESS;
-
+    
 #else // IPV6 not defined
+
     if( (m_Sock = socket( PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
     {
         ReportError();
-        
-        logExitWithBoolean(bSuccess)
-
-        return bSuccess;
-    }
-
-    // If the transport was initilised, then create client and server sockets.
-    sockaddr_in clAddr;
-    memset(&clAddr, 0, sizeof(sockaddr_in));
-
-    clAddr.sin_family = AF_INET;    // AF_INET (address family Internet).
-    clAddr.sin_port = 0;            // No Specify Port required.
-    clAddr.sin_addr.s_addr = INADDR_ANY;
-
-    // Attempt to bind the client to the client socket.
-    if( bind( m_Sock, (struct sockaddr *) &clAddr, sizeof( clAddr)) == SOCKET_ERROR)
-    {
-        ReportError();        
         CloseChannel();
-        
-        logExitWithBoolean(bSuccess)
+          
+        logThrowExceptionWithData("HTTPTransportException - SERVER_TRANSPORT_SOCKET_CREATE_ERROR", m_LastError.c_str())
 
-        return bSuccess;
+        throw HTTPTransportException( SERVER_TRANSPORT_SOCKET_CREATE_ERROR, m_LastError.c_str());
     }
 
-    // Although the above fragment makes use of the bind() API, it would be
-    // just as effective to skip over this call as there are no specific
-    // local port ID requirements for this client. The only advantage that
-    // bind() offers is the accessibility of the port which the system 
-    // chose via the .sin_port member of the cli_addr structure which will 
-    // be set upon success of the bind() call.
-
-    // Create the Server (Tx) side.
-
+    // Connect to server.
     sockaddr_in         svAddr;
     struct hostent *    pHostEntry = NULL;
     const char *        host = m_URL.getHostName();
@@ -616,34 +592,91 @@ OpenChannel()
 #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)
+        
+    // If connect timeout specified do non-blocking connect.
+    if (m_lConnectTimeoutSeconds > 0)
     {
-        // This must be done first thing to get proper error. Generate full message.
-        ReportError();
-        char buffer[100];
-        sprintf(buffer, "%d", m_URL.getPort());
-        string fullMessage = "Failed to open connection to server at host " +
-                             string(m_URL.getHostName()) + 
-                             " and port " +  string(buffer) + ".\n" + m_LastError;
+       // Make socket non-blocking
+       PLATFORM_SET_SOCKET_NONBLOCKING(m_Sock);
 
-        CloseChannel();
+       rc = connect( m_Sock, (struct sockaddr *) &svAddr, sizeof (svAddr));
+       
+       if (rc == SOCKET_ERROR && GETLASTERROR == EINPROGRESS)
+       { 
+            int iTimeoutStatus = applyTimeout(m_lConnectTimeoutSeconds, false);
 
-        m_LastError = fullMessage;
+            // Set to blocking mode again... 
+            PLATFORM_SET_SOCKET_BLOCKING(m_Sock);
+            
+            // Handle timeout outcome
+            if( iTimeoutStatus < 0)
+            {
+                CloseChannel();
+            
+                logThrowExceptionWithData("HTTPTransportException - SERVER_TRANSPORT_TIMEOUT_EXCEPTION", m_LastError.c_str())
 
-        logExitWithBoolean(bSuccess)
+                throw HTTPTransportException( SERVER_TRANSPORT_TIMEOUT_EXCEPTION, m_LastError.c_str());
+            }
+            else if( iTimeoutStatus == 0)
+            {
+                CloseChannel();
+                char buffer[100];
+                sprintf(buffer, "%d", m_URL.getPort());
+                m_LastError = 
+                  "Failed to open connection to server at host " +
+                   string(m_URL.getHostName()) + " and port " +  string(buffer) + ".\nConnect operation timed-out.";
+        
+                logThrowExceptionWithData("HTTPTransportException - SERVER_TRANSPORT_TIMEOUT_EXPIRED", m_LastError.c_str())
 
-        return bSuccess;
+                throw HTTPTransportException( SERVER_TRANSPORT_TIMEOUT_EXPIRED, m_LastError.c_str() );
+            }
+            else
+            {
+                // Otherwise, the socket either connected or there is an error.  If there is an error, we will
+                // get the error when we write to the socket so assume everything is OK.
+            
+                rc = 0;
+            }
+       }
+       else if (rc == SOCKET_ERROR)
+       {
+            // This must be done first thing to get proper error. Generate full message.
+            ReportError(true);
+            PLATFORM_SET_SOCKET_BLOCKING(m_Sock);
+            CloseChannel();
+       }
+       else
+       {
+            // Connected...
+            // Set to blocking mode again... 
+            PLATFORM_SET_SOCKET_BLOCKING(m_Sock);
+       }
     }
     else
-        bSuccess = AXIS_SUCCESS;
+    {
+        rc = connect( m_Sock, (struct sockaddr *) &svAddr, sizeof (svAddr));
 
-#endif // IPV6
+        // This must be done first thing to get proper error. Generate full message.
+        if (rc  == SOCKET_ERROR)
+        {
+            ReportError(true);  
+            CloseChannel();
+        }      
+    }
+
+    // If errors on connect, throw an exception.
+    if (rc == SOCKET_ERROR)
+    {
+        logThrowExceptionWithData("HTTPTransportException - SERVER_TRANSPORT_SOCKET_CONNECT_ERROR", m_LastError.c_str())
 
-    /* Turn off the Nagle algorithm - Patch by Steve Hardy */
+        throw HTTPTransportException( SERVER_TRANSPORT_SOCKET_CONNECT_ERROR, m_LastError.c_str());
+    }
+
+#endif // IPV6
 
-    /* This is needed, because our TCP stack would otherwise wait at most
+    /* Turn off the Nagle algorithm
+     *
+     * This is needed, because our TCP stack would otherwise wait at most
      * 200 ms before actually sending data to the server (while waiting for
      * a full packet). This limits performance to around 5 requests per
      * second, which is not acceptable. Turning off the Nagle algorithm
@@ -654,9 +687,9 @@ OpenChannel()
     int one = 1;
     setsockopt( m_Sock, IPPROTO_TCP, TCP_NODELAY, (char *) &one, sizeof( int));
 
-    logExitWithBoolean(bSuccess)
+    logExitWithBoolean(AXIS_SUCCESS)
 
-    return bSuccess;
+    return AXIS_SUCCESS;
 }
 
 /**
@@ -770,23 +803,30 @@ StopSockets()
  */
 
 int HTTPChannel::
-applyTimeout()
+applyTimeout(long seconds, bool isRead)
 {
     logEntryTransport("HTTPChannel::applyTimeout")
 
     fd_set          set;
+    fd_set          eset;
     struct timeval  timeout;
 
     // Initialize the file descriptor set.
     FD_ZERO( &set);
+    FD_ZERO( &eset);
     FD_SET( m_Sock, &set);
+    FD_SET( m_Sock, &eset);
 
     /* Initialize the timeout data structure. */
-    timeout.tv_sec = m_lTimeoutSeconds;
+    timeout.tv_sec = seconds;
     timeout.tv_usec = 0;
 
     /* select returns 0 if timeout, 1 if input available, -1 if error. */
-    int rc = select( FD_SETSIZE, &set, NULL, NULL, &timeout);
+    int rc;
+    if (isRead)
+        rc = select( FD_SETSIZE, &set, NULL, &eset, &timeout);
+    else
+        rc = select( FD_SETSIZE, NULL, &set, &eset, &timeout);
     
     if (rc < 0)
         ReportError();
@@ -797,12 +837,22 @@ applyTimeout()
 }
 
 void HTTPChannel::
-ReportError()
+ReportError(bool isConnectError)
 {
     long dwError = GETLASTERROR;
     char pcErr[100];
     sprintf(pcErr,"Error is %d - ",(int)dwError);
     m_LastError = string(pcErr) + PLATFORM_GET_ERROR_MESSAGE(dwError);
+    
+    if (isConnectError)
+    {
+        char buffer[100];
+        sprintf(buffer, "%d", m_URL.getPort());
+        string fullMessage = 
+                "Failed to open connection to server at host " +
+                string(m_URL.getHostName()) + " and port " +  string(buffer) + ".\n" + m_LastError;            
+        m_LastError = fullMessage;
+    }
 }
 
 void HTTPChannel::

Modified: axis/axis1/c/trunk/src/transport/axis3/HTTPChannel/HTTPChannel.hpp
URL: http://svn.apache.org/viewvc/axis/axis1/c/trunk/src/transport/axis3/HTTPChannel/HTTPChannel.hpp?rev=1337028&r1=1337027&r2=1337028&view=diff
==============================================================================
--- axis/axis1/c/trunk/src/transport/axis3/HTTPChannel/HTTPChannel.hpp (original)
+++ axis/axis1/c/trunk/src/transport/axis3/HTTPChannel/HTTPChannel.hpp Fri May 11 05:13:01 2012
@@ -30,6 +30,10 @@
 #include <ws2tcpip.h>
 #endif
 
+#ifndef EINPROGRESS
+#define EINPROGRESS WSAEINPROGRESS
+#endif
+
 // What version of WinSock is required
 const int    WS_VERSION_REQD    = 0x0101;
 
@@ -43,14 +47,13 @@ inline int WS_VERSION_MINOR() {return LO
 #include "../HTTPTransportException.hpp"
 
 #include <unistd.h>
-#include <sys/types.h>        // basic system data types
-#include <sys/socket.h>        // basic socket definitions
+#include <sys/types.h>
+#include <sys/socket.h>
 #include <netinet/tcp.h>
-#include <fcntl.h>            // for nonblocking if need
 #include <sys/time.h>
 #include <netdb.h>
 #include <netinet/in.h>
-#include <arpa/inet.h>        // inet(3) functions
+#include <arpa/inet.h>
 
 const int          INVALID_SOCKET = -1;
 const int          SOCKET_ERROR   = -1;
@@ -68,15 +71,16 @@ public:
 
     const char *        getURL();
     virtual void        setURL( const char * cpURL);
-    virtual URL &        getURLObject();
+    virtual URL &       getURLObject();
     bool                open();
     bool                close();
-    const std::string &    GetLastErrorMsg();
+    const std::string & GetLastErrorMsg();
     int                 readBytes(char *buf, int bufLen);
     int                 writeBytes(const char *buf, int numBytes);
     void                setTimeout( long lSeconds);
+    void                setConnectTimeout( long lSeconds);
     void                setSocket( unsigned int uiNewSocket);
-    int                    getSocket() {return m_Sock;}
+    int                 getSocket() {return m_Sock;}
     bool                setTransportProperty( AXIS_TRANSPORT_INFORMATION_TYPE type, const char * value);
     const char *        getTransportProperty( AXIS_TRANSPORT_INFORMATION_TYPE type);
     void                setProxy( const char * pcProxyHost, unsigned int uiProxyPort);
@@ -90,21 +94,22 @@ protected:
     void                CloseChannel();
     bool                StartSockets();
     void                StopSockets();
-    int                    applyTimeout();
-    void                ReportError();
+    int                 applyTimeout(long seconds, bool isRead);
+    void                ReportError(bool isConnectError=false);
 
 private:
-    URL                m_URL;                // URL
-    string            m_LastError;        // Last error
+    URL             m_URL;                      // URL
+    string          m_LastError;                // Last error
 #ifdef WIN32
     unsigned 
 #endif
-    int                m_Sock;                        // Socket descriptor
+    int             m_Sock;                     // Socket descriptor
     bool            m_bUseProxy;                // Use a Proxy?
-    std::string        m_strProxyHost;                // Proxy server name.
-    unsigned int    m_uiProxyPort;                // Proxy server port.
-    long            m_lTimeoutSeconds;            // Timeout in seconds
-    bool            bNoExceptionOnForceClose;    // If the socket is forcably closed, usually an
+    std::string     m_strProxyHost;             // Proxy server name.
+    unsigned int    m_uiProxyPort;              // Proxy server port.
+    long            m_lTimeoutSeconds;          // Timeout in seconds
+    long            m_lConnectTimeoutSeconds;   // Connect timeout in seconds
+    bool            bNoExceptionOnForceClose;   // If the socket is forcably closed, usually an
                                                 // exception is thrown.  When this flag is set,
                                                 // nothing happens (but the m_Sock is set to 0).
 };

Modified: axis/axis1/c/trunk/src/transport/axis3/HTTPSSLChannel/HTTPSSLChannel.cpp
URL: http://svn.apache.org/viewvc/axis/axis1/c/trunk/src/transport/axis3/HTTPSSLChannel/HTTPSSLChannel.cpp?rev=1337028&r1=1337027&r2=1337028&view=diff
==============================================================================
--- axis/axis1/c/trunk/src/transport/axis3/HTTPSSLChannel/HTTPSSLChannel.cpp (original)
+++ axis/axis1/c/trunk/src/transport/axis3/HTTPSSLChannel/HTTPSSLChannel.cpp Fri May 11 05:13:01 2012
@@ -62,6 +62,7 @@ HTTPSSLChannel()
 #else
     m_lTimeoutSeconds = 0;
 #endif
+    m_lConnectTimeoutSeconds = 0;
 
     bNoExceptionOnForceClose = false;
 
@@ -194,16 +195,16 @@ GetLastErrorMsg()
 /**
  * HTTPSSLChannel::operator >> (char * msg)
  *
- * This method attempts to read a message from the curently open channel.  If
+ * This method attempts to read a message from the currently open channel.  If
  * there is no currently open channel, then the method throws an exception.  If
- * there is an open channel, but nothing to recieve, then then method will
- * timeout and throw an exception.  If the mesage is interrupted or the
+ * there is an open channel, but nothing to receive, then then method will
+ * timeout and throw an exception.  If the message is interrupted or the
  * transmitting side closes then an exception is thrown.
  *
  * @param character pointer containing an array of character that can be filled
- * by the reieved message (NB: The maximum message length is BUF_SIZE).
+ * by the received message (NB: The maximum message length is BUF_SIZE).
  * @return character pointer pointing to the array of character containing the
- * recieved message.
+ * received message.
  */
 
 int HTTPSSLChannel::
@@ -421,9 +422,9 @@ readProxyConnect(char* buf, int bufLen)
     int iBufSize = bufLen - 10;
 
     // If timeout set then wait for maximum amount of time for data
-    if (m_lTimeoutSeconds)
+    if (m_lTimeoutSeconds > 0)
     {
-        int iTimeoutStatus = applyTimeout();
+        int iTimeoutStatus = applyTimeout(m_lTimeoutSeconds);
 
         // Handle timeout outcome
         if (iTimeoutStatus < 0)
@@ -479,6 +480,20 @@ setTimeout( long lSeconds)
 }
 
 /**
+ * HTTPSSLChannel::setConnectTimeout( const long lSeconds)
+ *
+ * Set the connect timeout (in seconds)
+ *
+ * @param long containing timeout value in seconds
+ */
+
+void HTTPSSLChannel::
+setConnectTimeout( long lSeconds)
+{
+    m_lConnectTimeoutSeconds = lSeconds;
+}
+
+/**
  * HTTPSSLChannel::setSocket( unsigned int uiNewSocket)
  *
  * This is used by the server side to change the server socket.
@@ -625,24 +640,12 @@ OpenChannel()
 
         if( connect( m_Sock, paiAddrInfo->ai_addr, paiAddrInfo->ai_addrlen) < 0)
         {
-            // Cannot open a channel to the remote end, shutting down the
-            // channel and then throw an exception.
-            // Before we do anything else get the last error message;
-            long dwError = GETLASTERROR;
-
+            ReportError(GETLASTERROR, false, true);
             CloseChannel();
 
             freeaddrinfo( paiAddrInfo0);
 
-            char pcErr[64], pcPort[64];
-            sprintf(pcErr,"%d - ",(int)dwError);
-            sprintf(pcPort,"%d",(int)m_URL.getPort());
-            
-            string fullMessage = "Failed to open connection to server " + 
-                   string(m_URL.getHostName()) + " at port " + string(pcPort) +
-                   ".\nError " + string(pcErr) + PLATFORM_GET_ERROR_MESSAGE( dwError );
-
-            throw HTTPTransportException( CLIENT_TRANSPORT_OPEN_CONNECTION_FAILED, fullMessage.c_str());
+            throw HTTPTransportException( CLIENT_TRANSPORT_OPEN_CONNECTION_FAILED, m_LastError.c_str());
         }
 
         break;
@@ -663,36 +666,16 @@ OpenChannel()
     bSuccess = AXIS_SUCCESS;
 
 #else // IPV6 not defined
-    if( (m_Sock = socket( PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
-    {
-        m_LastError = "Could not Create a socket.";
-
-        return bSuccess;
-    }
 
-    // If the transport was initilised, then create client and server sockets.
-    sockaddr_in    clAddr;
-
-    clAddr.sin_family = AF_INET;    // AF_INET (address family Internet).
-    clAddr.sin_port = 0;            // No Specify Port required.
-    clAddr.sin_addr.s_addr = INADDR_ANY;
-
-    // Attempt to bind the client to the client socket.
-    if( bind( m_Sock, (struct sockaddr *) &clAddr, sizeof( clAddr)) == SOCKET_ERROR)
+    if( (m_Sock = socket( PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
     {
+        ReportError(GETLASTERROR, false);
         CloseChannel();
-        m_LastError = "Error whilst binding. Cannot open a channel to the remote end.";
-        return bSuccess;
+
+        throw HTTPTransportException( SERVER_TRANSPORT_SOCKET_CREATE_ERROR, m_LastError.c_str());
     }
 
-    // Although the above fragment makes use of the bind() API, it would be
-    // just as effective to skip over this call as there are no specific
-    // local port ID requirements for this client. The only advantage that
-    // bind() offers is the accessibility of the port which the system 
-    // chose via the .sin_port member of the cli_addr structure which will 
-    // be set upon success of the bind() call.
-    
-    // Create the Server (Tx) side.
+    // Connect to server.
 
     sockaddr_in            svAddr;
     struct hostent *    pHostEntry = NULL;
@@ -718,27 +701,76 @@ OpenChannel()
     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)
+    // If connect timeout specified do non-blocking connect.
+    if (m_lConnectTimeoutSeconds > 0)
     {
-        long dwError = GETLASTERROR;
-        CloseChannel();
+       // Make socket non-blocking
+       PLATFORM_SET_SOCKET_NONBLOCKING(m_Sock);
 
-        char pcErr[64], pcPort[64];
-        sprintf(pcErr,"%d - ",(int)dwError);
-        sprintf(pcPort,"%d",(int)m_URL.getPort());
-        
-        string fullMessage = "Failed to open connection to server " + 
-               string(m_URL.getHostName()) + " at port " + string(pcPort) +
-               ".\nError " + string(pcErr) + PLATFORM_GET_ERROR_MESSAGE( dwError );
+       rc = connect( m_Sock, (struct sockaddr *) &svAddr, sizeof (svAddr));
 
-        m_LastError = fullMessage;
+       if (rc == SOCKET_ERROR && GETLASTERROR == EINPROGRESS)
+       {
+            int iTimeoutStatus = applyTimeout(m_lConnectTimeoutSeconds, false);
 
-        return bSuccess;
+            // Set to blocking mode again...
+            PLATFORM_SET_SOCKET_BLOCKING(m_Sock);
+
+            // Handle timeout outcome
+            if( iTimeoutStatus < 0)
+            {
+                CloseChannel();
+                throw HTTPTransportException( SERVER_TRANSPORT_TIMEOUT_EXCEPTION, m_LastError.c_str());
+            }
+            else if( iTimeoutStatus == 0)
+            {
+                CloseChannel();
+                char buffer[100];
+                sprintf(buffer, "%d", m_URL.getPort());
+                m_LastError =
+                  "Failed to open connection to server at host " +
+                   string(m_URL.getHostName()) + " and port " +  string(buffer) + ".\nConnect operation timed-out.";
+
+                throw HTTPTransportException( SERVER_TRANSPORT_TIMEOUT_EXPIRED, m_LastError.c_str() );
+            }
+            else
+            {
+                // Otherwise, the socket either connected or there is an error.  If there is an error, we will
+                // get the error when we write to the socket so assume everything is OK.
+
+                rc = 0;
+            }
+       }
+       else if (rc == SOCKET_ERROR)
+       {
+            // This must be done first thing to get proper error. Generate full message.
+            ReportError(GETLASTERROR, false, true);
+            PLATFORM_SET_SOCKET_BLOCKING(m_Sock);
+            CloseChannel();
+       }
+       else
+       {
+            // Connected...
+            // Set to blocking mode again...
+            PLATFORM_SET_SOCKET_BLOCKING(m_Sock);
+       }
     }
     else
     {
-        bSuccess = AXIS_SUCCESS;
+        rc = connect( m_Sock, (struct sockaddr *) &svAddr, sizeof (svAddr));
+
+        // This must be done first thing to get proper error. Generate full message.
+        if (rc  == SOCKET_ERROR)
+        {
+            ReportError(GETLASTERROR, false, true);
+            CloseChannel();
+        }
+    }
+
+    // If errors on connect, throw an exception.
+    if (rc == SOCKET_ERROR)
+    {
+        throw HTTPTransportException( SERVER_TRANSPORT_SOCKET_CONNECT_ERROR, m_LastError.c_str());
     }
 
 #endif // IPV6
@@ -754,7 +786,6 @@ OpenChannel()
      */
 
     int one = 1;
-
     setsockopt( m_Sock, IPPROTO_TCP, TCP_NODELAY, (char *)&one, sizeof(int));
 
     if(m_bUseProxy)
@@ -869,21 +900,64 @@ StopSockets()
  */
 
 int HTTPSSLChannel::
-applyTimeout()
+applyTimeout(long seconds, bool isRead)
 {
     fd_set            set;
+    fd_set            eset;
     struct timeval    timeout;
 
     // Initialize the file descriptor set.
     FD_ZERO( &set);
+    FD_ZERO( &eset);
     FD_SET( m_Sock, &set);
+    FD_SET( m_Sock, &eset);
 
     /* Initialize the timeout data structure. */
-    timeout.tv_sec = m_lTimeoutSeconds;
+    timeout.tv_sec = seconds;
     timeout.tv_usec = 0;
 
     /* select returns 0 if timeout, 1 if input available, -1 if error. */
-    return select( FD_SETSIZE, &set, NULL, NULL, &timeout);
+    int rc;
+    if (isRead)
+        rc = select( FD_SETSIZE, &set, NULL, &eset, &timeout);
+    else
+        rc = select( FD_SETSIZE, NULL, &set, &eset, &timeout);
+
+    if (rc < 0)
+        ReportError(GETLASTERROR, false);
+
+    return rc;
+}
+
+/**
+ * HTTPGSkitChannel::ReportError()
+ *
+ * Protected function
+ *
+ * @return int
+ */
+
+void HTTPSSLChannel::
+ReportError( int rc, bool errorIsSSL, bool isConnectError)
+{
+    char    szError[100];
+    sprintf( szError, "%d", rc);
+    char    szSSLErrorBuffer[220];
+
+    if (errorIsSSL)
+        m_LastError = "SSL Error is " + std::string( szError) + " - " + ERR_error_string( rc, szSSLErrorBuffer);
+    else
+        m_LastError = "Error is " + std::string(szError) + " - " + PLATFORM_GET_ERROR_MESSAGE(rc);
+
+    if (isConnectError)
+    {
+        char buffer[100];
+        sprintf(buffer, "%d", m_URL.getPort());
+        string fullMessage =
+                "Failed to open connection to server at host " +
+                string(m_URL.getHostName()) + " and port " +  string(buffer) + ".\n" + m_LastError;
+        m_LastError = fullMessage;
+    }
 }
 
 /**

Modified: axis/axis1/c/trunk/src/transport/axis3/HTTPSSLChannel/HTTPSSLChannel.hpp
URL: http://svn.apache.org/viewvc/axis/axis1/c/trunk/src/transport/axis3/HTTPSSLChannel/HTTPSSLChannel.hpp?rev=1337028&r1=1337027&r2=1337028&view=diff
==============================================================================
--- axis/axis1/c/trunk/src/transport/axis3/HTTPSSLChannel/HTTPSSLChannel.hpp (original)
+++ axis/axis1/c/trunk/src/transport/axis3/HTTPSSLChannel/HTTPSSLChannel.hpp Fri May 11 05:13:01 2012
@@ -32,6 +32,10 @@
 #include <ws2tcpip.h>
 #endif
 
+#ifndef EINPROGRESS
+#define EINPROGRESS WSAEINPROGRESS
+#endif
+
 // What version of WinSock is required
 const int    WS_VERSION_REQD    = 0x0101;
 
@@ -45,14 +49,14 @@ inline int WS_VERSION_MINOR() {return LO
 #include "../HTTPTransportException.hpp"
 
 #include <unistd.h>
-#include <sys/types.h>		// basic system data types
-#include <sys/socket.h>		// basic socket definitions
+#include <sys/types.h>
+#include <sys/socket.h>
 #include <netinet/tcp.h>
-#include <fcntl.h>			// for nonblocking if need
+#include <fcntl.h>            // for nonblocking if need
 #include <sys/time.h>
 #include <netdb.h>
 #include <netinet/in.h>
-#include <arpa/inet.h>		// inet(3) functions
+#include <arpa/inet.h>
 
 const int          INVALID_SOCKET = -1;
 const int          SOCKET_ERROR   = -1;
@@ -65,56 +69,59 @@ AXIS_CPP_NAMESPACE_USE using namespace s
 class HTTPSSLChannel:public IChannel
 {
 public:
-	HTTPSSLChannel();
-	virtual ~HTTPSSLChannel();
+    HTTPSSLChannel();
+    virtual ~HTTPSSLChannel();
 
-	const char *		getURL();
-	virtual void		setURL( const char * cpURL);
-    virtual URL &		getURLObject();
-    bool				open();
-    bool				close();
-    const std::string &	GetLastErrorMsg();
+    const char *        getURL();
+    virtual void        setURL( const char * cpURL);
+    virtual URL &       getURLObject();
+    bool                open();
+    bool                close();
+    const std::string & GetLastErrorMsg();
     int                 readBytes(char *buf, int bufLen);
     int                 writeBytes(const char *buf, int numBytes);
-    void				setTimeout( long lSeconds);
-    void				setSocket( unsigned int uiNewSocket);
-	int					getSocket() {return m_Sock;}
-	bool				setTransportProperty( AXIS_TRANSPORT_INFORMATION_TYPE type, const char* value);
-	const char *		getTransportProperty( AXIS_TRANSPORT_INFORMATION_TYPE type);
-    void				setProxy( const char * pcProxyHost, unsigned int uiProxyPort);
-	bool		        reopenRequired() { return (INVALID_SOCKET == m_Sock); }
-	void				closeQuietly( bool bNoExceptionOnForceClose);
+    void                setTimeout( long lSeconds);
+    void                setConnectTimeout( long lSeconds);
+    void                setSocket( unsigned int uiNewSocket);
+    int                 getSocket() {return m_Sock;}
+    bool                setTransportProperty( AXIS_TRANSPORT_INFORMATION_TYPE type, const char* value);
+    const char *        getTransportProperty( AXIS_TRANSPORT_INFORMATION_TYPE type);
+    void                setProxy( const char * pcProxyHost, unsigned int uiProxyPort);
+    bool                reopenRequired() { return (INVALID_SOCKET == m_Sock); }
+    void                closeQuietly( bool bNoExceptionOnForceClose);
 
 protected:
-	bool				OpenChannel();
-	void				CloseChannel();
-	bool				StartSockets();
-	void				StopSockets();
-	int					applyTimeout();
-	void				OpenSSL_Initialise();
-	bool				OpenSSL_Open();
-	int					OpenSSL_Close();
-	void				OpenSSL_SetSecureError( int iError);
+    bool                OpenChannel();
+    void                CloseChannel();
+    bool                StartSockets();
+    void                StopSockets();
+    int                 applyTimeout(long seconds, bool isRead);
+    void                ReportError( int rc, bool isSSLError=true, bool isConnectError=false);
+    void                OpenSSL_Initialise();
+    bool                OpenSSL_Open();
+    int                 OpenSSL_Close();
+    void                OpenSSL_SetSecureError( int iError);
     bool                proxyConnect();
     int                 writeProxyConnect();
     int                 readProxyConnect(char* buf, int bufLen);
 
 private:
-    URL				m_URL;				// URL
-	string			m_LastError;		// Last error
+    URL               m_URL;                    // URL
+    string            m_LastError;              // Last error
 #ifdef WIN32
     unsigned 
 #endif
-    int				m_Sock;						// Socket descriptor
-	SSL_CTX *		m_sslContext;
-	SSL *			m_sslHandle;
-    bool			m_bUseProxy;				// Use a Proxy?
-    std::string		m_strProxyHost;				// Proxy server name.
-    unsigned int	m_uiProxyPort;				// Proxy server port.
-    long			m_lTimeoutSeconds;			// Timeout in seconds
-	bool			bNoExceptionOnForceClose;	// If the socket is forcably closed, usually an
-												// exception is thrown.  When this flag is set,
-												// nothing happens (but the m_Sock is set to 0).
+    int             m_Sock;                     // Socket descriptor
+    SSL_CTX *       m_sslContext;
+    SSL *           m_sslHandle;
+    bool            m_bUseProxy;                // Use a Proxy?
+    std::string     m_strProxyHost;             // Proxy server name.
+    unsigned int    m_uiProxyPort;              // Proxy server port.
+    long            m_lTimeoutSeconds;          // Timeout in seconds
+    long            m_lConnectTimeoutSeconds;   // Connect timeout in seconds
+    bool            bNoExceptionOnForceClose;   // If the socket is forcably closed, usually an
+                                                // exception is thrown.  When this flag is set,
+                                                // nothing happens (but the m_Sock is set to 0).
 };
 
 #endif

Modified: axis/axis1/c/trunk/src/transport/axis3/HTTPTransport.cpp
URL: http://svn.apache.org/viewvc/axis/axis1/c/trunk/src/transport/axis3/HTTPTransport.cpp?rev=1337028&r1=1337027&r2=1337028&view=diff
==============================================================================
--- axis/axis1/c/trunk/src/transport/axis3/HTTPTransport.cpp (original)
+++ axis/axis1/c/trunk/src/transport/axis3/HTTPTransport.cpp Fri May 11 05:13:01 2012
@@ -15,11 +15,6 @@
 *   limitations under the License.
 */
 
-/*
- * @author Samisa Abeysinghe (sabeysinghe@virtusa.com)
- *
- */
-
 // !!! This include file must be first thing in file !!!
 #include "../../platforms/PlatformAutoSense.hpp"
 
@@ -70,9 +65,13 @@ m_bMaintainSession (false)
     m_pcPassword=NULL;
 #ifdef WIN32
     m_lChannelTimeout = 10;
+    m_strChannelTimeout = "10";
 #else
     m_lChannelTimeout = 0;
+    m_strChannelTimeout = "0";
 #endif
+    m_lChannelConnectTimeout = 0;
+    m_strChannelConnectTimeout = "0";
     m_strResponseLocationURI = "";
     m_bPerformAutoRedirect = false;
     m_iMaximumAutoRedirects = 1;
@@ -220,7 +219,10 @@ setEndpointUri( const char * pcEndpointU
     // channel was created, then it may not have the correct timeout. By setting it here, 
     // the channel is sure to have the correct timeout value next time the channel is read.
     if( m_pActiveChannel != NULL)
+    {
         m_pActiveChannel->setTimeout( m_lChannelTimeout);
+        m_pActiveChannel->setConnectTimeout( m_lChannelConnectTimeout);
+    }
     
     logExit()
 }
@@ -993,6 +995,22 @@ setTransportProperty( AXIS_TRANSPORT_INF
             break;
         }
 
+        case IO_TIMEOUT:
+        {
+            if (value)
+                setTimeout((long)atoi(value));
+
+            break;
+        }
+
+        case CONNECT_TIMEOUT:
+        {
+            if (value)
+                setConnectTimeout((long)atoi(value));
+
+            break;
+        }
+
         default:
         {
             break;
@@ -1136,6 +1154,21 @@ getTransportProperty( AXIS_TRANSPORT_INF
             pszPropValue = m_strMaximumAutoRedirects.c_str();
             break;
         }
+
+
+        case IO_TIMEOUT:
+        {
+            pszPropValue = m_strChannelTimeout.c_str();
+
+            break;
+        }
+
+        case CONNECT_TIMEOUT:
+        {
+            pszPropValue = m_strChannelConnectTimeout.c_str();
+
+            break;
+        }
     }
 
     logExitWithString(pszPropValue)
@@ -1259,11 +1292,41 @@ setTimeout( long lSeconds)
 {
     logEntryTransport("HTTPTransport::setTimeout")
 
+    logDebugArg1("I/O timeout: %d", lSeconds)
+
     if( m_pActiveChannel != NULL)
         m_pActiveChannel->setTimeout( lSeconds);
 
     m_lChannelTimeout = lSeconds;
     
+    char buffer[100];
+    sprintf(buffer, "%d", m_lChannelTimeout);
+    m_strChannelTimeout = (const char *)buffer;
+
+    logExit()
+}
+
+/* HTTPTransport::setConnectTimeout( Timeout) Is a public method for setting the
+ * current maximum connect timeout.
+ *
+ * @param long Timeout is a long value in seconds.
+ */
+void HTTPTransport::
+setConnectTimeout( long lSeconds)
+{
+    logEntryTransport("HTTPTransport::setConnectTimeout")
+
+    logDebugArg1("Connect timeout: %d", lSeconds)
+
+    if( m_pActiveChannel != NULL)
+        m_pActiveChannel->setConnectTimeout( lSeconds);
+
+    m_lChannelConnectTimeout = lSeconds;
+
+    char buffer[100];
+    sprintf(buffer, "%d", m_lChannelConnectTimeout);
+    m_strChannelConnectTimeout = (const char *)buffer;
+
     logExit()
 }
 

Modified: axis/axis1/c/trunk/src/transport/axis3/HTTPTransport.hpp
URL: http://svn.apache.org/viewvc/axis/axis1/c/trunk/src/transport/axis3/HTTPTransport.hpp?rev=1337028&r1=1337027&r2=1337028&view=diff
==============================================================================
--- axis/axis1/c/trunk/src/transport/axis3/HTTPTransport.hpp (original)
+++ axis/axis1/c/trunk/src/transport/axis3/HTTPTransport.hpp Fri May 11 05:13:01 2012
@@ -16,9 +16,6 @@
  */
 
 /*
- * @author Samisa Abeysinghe (sabeysinghe@virtusa.com)
- * @author hawkeye (hawkinsj@uk.ibm.com) - improved cookie support
- * 
  * KNOWN LIMITATIONS: 
  * Cookie support: 
  * 1) Cookies are maintained over the life time of a connection only and are not persisted.
@@ -89,6 +86,7 @@ class HTTPTransport:public SOAPTransport
     AXIS_TRANSPORT_STATUS   flushOutput() throw (AxisException, HTTPTransportException);
     void                    setProxy( const char *pcProxyHost, unsigned int uiProxyPort);
     void                    setTimeout( long lSeconds);
+    void                    setConnectTimeout( long lSeconds);
     const char *            getHTTPProtocol();
     const char *            getHTTPMethod();
     void                    setHTTPMethod( const char *);
@@ -320,7 +318,10 @@ class HTTPTransport:public SOAPTransport
 
     char *    m_pszRxBuffer;
 
-    long    m_lChannelTimeout;
+    long        m_lChannelTimeout;
+    std::string m_strChannelTimeout;
+    long        m_lChannelConnectTimeout;
+    std::string m_strChannelConnectTimeout;
 
     std::string    m_strBuffered;
 

Modified: axis/axis1/c/trunk/src/transport/axis3/IChannel.hpp
URL: http://svn.apache.org/viewvc/axis/axis1/c/trunk/src/transport/axis3/IChannel.hpp?rev=1337028&r1=1337027&r2=1337028&view=diff
==============================================================================
--- axis/axis1/c/trunk/src/transport/axis3/IChannel.hpp (original)
+++ axis/axis1/c/trunk/src/transport/axis3/IChannel.hpp Fri May 11 05:13:01 2012
@@ -87,6 +87,7 @@ public:
     virtual int                 setSecureProperties( const char *) {return true;};
     virtual const char *        getSecureProperties() {return NULL;};
     virtual void                setTimeout( long lSeconds)=0;
+    virtual void                setConnectTimeout( long lSeconds)=0;
     virtual void                setSocket( unsigned int uiNewSocket)=0;
     virtual int                 getSocket()=0;
     virtual bool                setTransportProperty( AXIS_TRANSPORT_INFORMATION_TYPE type, const char* value)=0;