You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2010/04/10 00:17:38 UTC

svn commit: r932637 [1/3] - in /activemq/activemq-cpp/trunk/activemq-cpp/src: main/ main/activemq/transport/tcp/ main/decaf/internal/net/tcp/ main/decaf/net/ test/decaf/net/

Author: tabish
Date: Fri Apr  9 22:17:38 2010
New Revision: 932637

URL: http://svn.apache.org/viewvc?rev=932637&view=rev
Log:
Refactored Socket package to allow for varied Socket types through a single Socket class wrapper.  Improved error handling code and new SocketFactory implementations.  

Added:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet4Address.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet4Address.h   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet6Address.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet6Address.h   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/InetAddress.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/InetAddress.h   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/InetSocketAddress.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/InetSocketAddress.h   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Socket.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketAddress.h   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketImplFactory.h   (with props)
Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/TcpTransport.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/DefaultSocketFactory.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocketInputStream.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocketInputStream.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocketOutputStream.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocketOutputStream.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ServerSocket.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ServerSocket.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Socket.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketImpl.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketImpl.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketOptions.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/SocketOptions.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/net/SocketFactoryTest.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/net/SocketFactoryTest.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/net/SocketTest.cpp

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am?rev=932637&r1=932636&r2=932637&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am Fri Apr  9 22:17:38 2010
@@ -545,7 +545,12 @@ cc_sources = \
     decaf/lang/System.cpp \
     decaf/lang/Thread.cpp \
     decaf/lang/ThreadGroup.cpp \
+    decaf/net/Inet4Address.cpp \
+    decaf/net/Inet6Address.cpp \
+    decaf/net/InetAddress.cpp \
+    decaf/net/InetSocketAddress.cpp \
     decaf/net/ServerSocket.cpp \
+    decaf/net/Socket.cpp \
     decaf/net/SocketError.cpp \
     decaf/net/SocketFactory.cpp \
     decaf/net/SocketImpl.cpp \
@@ -1242,16 +1247,22 @@ h_sources = \
     decaf/net/BindException.h \
     decaf/net/ConnectException.h \
     decaf/net/HttpRetryException.h \
+    decaf/net/Inet4Address.h \
+    decaf/net/Inet6Address.h \
+    decaf/net/InetAddress.h \
+    decaf/net/InetSocketAddress.h \
     decaf/net/MalformedURLException.h \
     decaf/net/NoRouteToHostException.h \
     decaf/net/PortUnreachableException.h \
     decaf/net/ProtocolException.h \
     decaf/net/ServerSocket.h \
     decaf/net/Socket.h \
+    decaf/net/SocketAddress.h \
     decaf/net/SocketError.h \
     decaf/net/SocketException.h \
     decaf/net/SocketFactory.h \
     decaf/net/SocketImpl.h \
+    decaf/net/SocketImplFactory.h \
     decaf/net/SocketOptions.h \
     decaf/net/SocketTimeoutException.h \
     decaf/net/URI.h \

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/TcpTransport.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/TcpTransport.cpp?rev=932637&r1=932636&r2=932637&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/TcpTransport.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/TcpTransport.cpp Fri Apr  9 22:17:38 2010
@@ -176,7 +176,7 @@ void TcpTransport::configureSocket( Sock
 
         // Get the linger flag.
         int soLinger = Integer::parseInt(
-            properties.getProperty( "soLinger", "0" ) );
+            properties.getProperty( "soLinger", "-1" ) );
 
         // Get the keepAlive flag.
         bool soKeepAlive = Boolean::parseBoolean(
@@ -194,18 +194,20 @@ void TcpTransport::configureSocket( Sock
         bool tcpNoDelay = Boolean::parseBoolean(
             properties.getProperty( "tcpNoDelay", "true" ) );
 
-        // Get the socket connect timeout in microseconds.
-        socket.setConnectTimeout(
-            Integer::parseInt( properties.getProperty( "soConnectTimeout", "-1" ) ) );
+        // Get the socket connect timeout in microseconds. (default to infinite wait).
+        int connectTimeout = Integer::parseInt( properties.getProperty( "soConnectTimeout", "0" ) );
 
         // Connect the socket.
-        socket.connect( host.c_str(), port );
+        socket.connect( host, port, connectTimeout );
 
         // Set the socket options.
-        socket.setSoLinger( soLinger );
         socket.setKeepAlive( soKeepAlive );
         socket.setTcpNoDelay( tcpNoDelay );
 
+        if( soLinger > 0 ) {
+            socket.setSoLinger( true, soLinger );
+        }
+
         if( soReceiveBufferSize > 0 ){
             socket.setReceiveBufferSize( soReceiveBufferSize );
         }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/DefaultSocketFactory.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/DefaultSocketFactory.cpp?rev=932637&r1=932636&r2=932637&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/DefaultSocketFactory.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/DefaultSocketFactory.cpp Fri Apr  9 22:17:38 2010
@@ -44,7 +44,14 @@ DefaultSocketFactory::~DefaultSocketFact
 Socket* DefaultSocketFactory::createSocket()
     throw( decaf::io::IOException ) {
 
-    return new TcpSocket();
+    try{
+
+        std::auto_ptr<Socket> theSocket( new Socket( new TcpSocket() ) );
+
+        return theSocket.release();
+    }
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCHALL_THROW( IOException )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -62,12 +69,13 @@ Socket* DefaultSocketFactory::createSock
             throw SocketException( __FILE__, __LINE__, "valid port not provided" );
         }
 
-        std::auto_ptr<TcpSocket> tcpSocket( new TcpSocket() );
+        std::auto_ptr<SocketImpl> tcpSocket( new TcpSocket() );
+        std::auto_ptr<Socket> socket( new Socket( tcpSocket.release() ) );
 
         // Connect the socket.
-        tcpSocket->connect( hostname.c_str(), port );
+        socket->connect( hostname.c_str(), port );
 
-        return tcpSocket.release();
+        return socket.release();
     }
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCH_EXCEPTION_CONVERT( Exception, IOException )

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.cpp?rev=932637&r1=932636&r2=932637&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.cpp Fri Apr  9 22:17:38 2010
@@ -21,6 +21,33 @@
 #include <decaf/internal/net/tcp/TcpSocketOutputStream.h>
 
 #include <decaf/net/SocketError.h>
+#include <decaf/net/SocketOptions.h>
+#include <decaf/lang/Character.h>
+#include <decaf/lang/exceptions/UnsupportedOperationException.h>
+#include <stdlib.h>
+#include <string>
+#include <stdio.h>
+#include <iostream>
+
+#include <apr_portable.h>
+
+#if !defined(HAVE_WINSOCK2_H)
+    #include <sys/select.h>
+    #include <sys/socket.h>
+#else
+    #include <Winsock2.h>
+#endif
+
+#ifdef HAVE_SYS_IOCTL_H
+#define BSD_COMP /* Get FIONREAD on Solaris2. */
+#include <sys/ioctl.h>
+#include <unistd.h>
+#endif
+
+// Pick up FIONREAD on Solaris 2.5.
+#ifdef HAVE_SYS_FILIO_H
+#include <sys/filio.h>
+#endif
 
 using namespace decaf;
 using namespace decaf::internal;
@@ -29,21 +56,16 @@ using namespace decaf::internal::net::tc
 using namespace decaf::net;
 using namespace decaf::io;
 using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
 
 ////////////////////////////////////////////////////////////////////////////////
 TcpSocket::TcpSocket() throw ( SocketException )
   : socketHandle( NULL ),
     inputStream( NULL ),
     outputStream( NULL ),
-    connectTimeout( -1 ) {
-}
-
-////////////////////////////////////////////////////////////////////////////////
-TcpSocket::TcpSocket( SocketHandle socketHandle )
- :  socketHandle( socketHandle ),
-    inputStream( new TcpSocketInputStream( socketHandle ) ),
-    outputStream( new TcpSocketOutputStream( socketHandle ) ),
-    connectTimeout( -1 ) {
+    inputShutdown( false ),
+    outputShutdown( false ),
+    closed( false ) {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -71,33 +93,139 @@ TcpSocket::~TcpSocket() {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-InputStream* TcpSocket::getInputStream(){
+void TcpSocket::create() throw( decaf::io::IOException ) {
+
+    try{
+
+        if( this->socketHandle != NULL ) {
+            throw IOException(
+                __FILE__, __LINE__, "The System level socket has already been created." );
+        }
+
+        // Create the actual socket.
+        checkResult( apr_socket_create( &socketHandle, AF_INET, SOCK_STREAM,
+                                        APR_PROTO_TCP, apr_pool.getAprPool() ) );
+    }
+    DECAF_CATCH_RETHROW( decaf::io::IOException )
+    DECAF_CATCH_EXCEPTION_CONVERT( Exception, decaf::io::IOException )
+    DECAF_CATCHALL_THROW( decaf::io::IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void TcpSocket::accept( SocketImpl* socket ) throw( decaf::io::IOException ) {
+
+    try{
+
+        if( socket == NULL ) {
+            throw IOException(
+                __FILE__, __LINE__, "SocketImpl instance passed was null." );
+        }
+
+        TcpSocket* impl = dynamic_cast<TcpSocket*>( socket );
+        if( impl == NULL ) {
+            throw IOException(
+                __FILE__, __LINE__, "SocketImpl instance passed was not a TcpSocket." );
+        }
+
+        apr_status_t result = APR_SUCCESS;
+
+        // Loop to ignore any signal interruptions that occur during the operation.
+        do {
+            result = apr_socket_accept( &impl->socketHandle, socketHandle, apr_pool.getAprPool() );
+        } while( result == APR_EINTR );
+
+        if( result != APR_SUCCESS ) {
+            throw SocketException(
+                  __FILE__, __LINE__,
+                  "ServerSocket::accept - %s",
+                  SocketError::getErrorString().c_str() );
+        }
+    }
+    DECAF_CATCH_RETHROW( decaf::io::IOException )
+    DECAF_CATCH_EXCEPTION_CONVERT( Exception, decaf::io::IOException )
+    DECAF_CATCHALL_THROW( decaf::io::IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+InputStream* TcpSocket::getInputStream() throw( IOException ) {
     return inputStream;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-OutputStream* TcpSocket::getOutputStream(){
+OutputStream* TcpSocket::getOutputStream() throw( IOException ) {
     return outputStream;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void TcpSocket::connect( const char* host, int port ) throw ( SocketException ) {
+void TcpSocket::bind( const std::string& ipaddress, int port )
+    throw( decaf::io::IOException ) {
+
+    try{
+
+        const char* host = ipaddress.empty() ? NULL : ipaddress.c_str();
+
+        // Create the Address Info for the Socket
+        apr_status_t result = apr_sockaddr_info_get(
+            &localAddress, host, APR_INET, (apr_port_t)port, 0, apr_pool.getAprPool() );
+
+        if( result != APR_SUCCESS ) {
+            socketHandle = NULL;
+            throw SocketException(
+                  __FILE__, __LINE__,
+                  SocketError::getErrorString().c_str() );
+        }
+
+        // Set the socket to reuse the address and default as blocking
+        apr_socket_opt_set( socketHandle, APR_SO_REUSEADDR, 1 );
+        apr_socket_opt_set( socketHandle, APR_SO_NONBLOCK, 0 );
+        apr_socket_timeout_set( socketHandle, -1 );
+
+        // Bind to the Socket, this may be where we find out if the port is in use.
+        result = apr_socket_bind( socketHandle, localAddress );
+
+        if( result != APR_SUCCESS ) {
+            close();
+            throw SocketException(
+                  __FILE__, __LINE__,
+                  "ServerSocket::bind - %s",
+                  SocketError::getErrorString().c_str() );
+        }
+    }
+    DECAF_CATCH_RETHROW( decaf::io::IOException )
+    DECAF_CATCH_EXCEPTION_CONVERT( Exception, decaf::io::IOException )
+    DECAF_CATCHALL_THROW( decaf::io::IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void TcpSocket::connect( const std::string& hostname, int port, int timeout )
+    throw( decaf::io::IOException,
+           decaf::lang::exceptions::IllegalArgumentException ) {
 
     try{
 
         if( isConnected() ) {
             throw SocketException( __FILE__, __LINE__,
-                "Socket::connect - Socket already connected.  host: %s, port: %d", host, port );
+                "Socket::connect - Socket already connected.  host: %s, port: %d", hostname.c_str(), port );
+        }
+
+        if( port < 0 || port > 65535 ) {
+            throw IllegalArgumentException(
+                __FILE__, __LINE__, "Given port is out of range: %d", port );
+        }
+
+        if( timeout < 0 ) {
+            throw IllegalArgumentException(
+                __FILE__, __LINE__, "Given timeout is out of range: %d", timeout );
+        }
+
+        if( this->socketHandle == NULL ) {
+            throw IOException(
+                __FILE__, __LINE__, "The socket was not yet created." );
         }
 
         // Create the Address data
         checkResult( apr_sockaddr_info_get(
-            &socketAddress, host, APR_INET, (apr_port_t)port, 0, apr_pool.getAprPool() ) );
-
-        // Create the actual socket.
-        checkResult( apr_socket_create(
-            &socketHandle, socketAddress->family, SOCK_STREAM,
-            APR_PROTO_TCP, apr_pool.getAprPool() ) );
+            &remoteAddress, hostname.c_str(), APR_INET, (apr_port_t)port, 0, apr_pool.getAprPool() ) );
 
         // To make blocking-with-timeout sockets, we have to set it to
         // 'APR_SO_NONBLOCK==1(on) and timeout>0'. On Unix, we have no
@@ -111,19 +239,19 @@ void TcpSocket::connect( const char* hos
         // If we have a connection timeout specified, temporarily set the socket to
         // non-blocking so that we can timeout the connect operation.  We'll restore
         // to blocking mode right after we connect.
-        apr_socket_opt_set( socketHandle, APR_SO_NONBLOCK, (this->connectTimeout > 0 ) ? 1 : 0 );
-        apr_socket_timeout_set( socketHandle, connectTimeout );
+        apr_socket_opt_set( socketHandle, APR_SO_NONBLOCK, (timeout > 0 ) ? 1 : 0 );
+        apr_socket_timeout_set( socketHandle, timeout );
 
         // try to Connect to the provided address.
-        checkResult(apr_socket_connect( socketHandle, socketAddress ));
+        checkResult(apr_socket_connect( socketHandle, remoteAddress ));
 
         // Now that we are connected, we want to go back to blocking.
         apr_socket_opt_set( socketHandle, APR_SO_NONBLOCK, 0 );
         apr_socket_timeout_set( socketHandle, -1 );
 
         // Create an input/output stream for this socket.
-        inputStream = new TcpSocketInputStream( socketHandle );
-        outputStream = new TcpSocketOutputStream( socketHandle );
+        inputStream = new TcpSocketInputStream( this );
+        outputStream = new TcpSocketOutputStream( this );
 
     } catch( SocketException& ex ) {
         ex.setMark( __FILE__, __LINE__);
@@ -138,9 +266,116 @@ void TcpSocket::connect( const char* hos
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+std::string TcpSocket::getLocalAddress() const {
+
+    if( !isClosed() ) {
+        SocketAddress addr;
+        checkResult( apr_socket_addr_get( &addr, APR_LOCAL, this->socketHandle ) );
+        char ipStr[20] = {0};
+        checkResult( apr_sockaddr_ip_getbuf( ipStr, 20, addr ) );
+
+        return std::string( ipStr, 20 );
+    }
+
+    return "0.0.0.0";
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void TcpSocket::listen( int backlog ) throw( decaf::io::IOException ) {
+
+    try{
+
+        if( isClosed() ){
+            throw IOException(
+                __FILE__, __LINE__, "The stream is closed" );
+        }
+
+        // Setup the listen for incoming connection requests
+        apr_status_t result = apr_socket_listen( socketHandle, backlog );
+
+        if( result != APR_SUCCESS ) {
+            close();
+            throw SocketException(
+                __FILE__, __LINE__, "Error on Bind - %s",
+                SocketError::getErrorString().c_str() );
+        }
+    }
+    DECAF_CATCH_RETHROW( decaf::io::IOException )
+    DECAF_CATCH_EXCEPTION_CONVERT( Exception, decaf::io::IOException )
+    DECAF_CATCHALL_THROW( decaf::io::IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int TcpSocket::available() throw( decaf::io::IOException ) {
+
+    if( isClosed() ){
+        throw IOException(
+            __FILE__, __LINE__, "The stream is closed" );
+    }
+
+    // Convert to an OS level socket.
+    apr_os_sock_t oss;
+    apr_os_sock_get( (apr_os_sock_t*)&oss, socketHandle );
+
+// The windows version
+#if defined(HAVE_WINSOCK2_H)
+
+    unsigned long numBytes = 0;
+
+    if( ::ioctlsocket( oss, FIONREAD, &numBytes ) == SOCKET_ERROR ){
+        throw SocketException( __FILE__, __LINE__, "ioctlsocket failed" );
+    }
+
+    return numBytes;
+
+#else // !defined(HAVE_WINSOCK2_H)
+
+    // If FIONREAD is defined - use ioctl to find out how many bytes
+    // are available.
+    #if defined(FIONREAD)
+
+        int numBytes = 0;
+        if( ::ioctl( oss, FIONREAD, &numBytes ) != -1 ){
+            return numBytes;
+        }
+
+    #endif
+
+    // If we didn't get anything we can use select.  This is a little
+    // less functional.  We will poll on the socket - if there is data
+    // available, we'll return 1, otherwise we'll return zero.
+    #if defined(HAVE_SELECT)
+
+        fd_set rd;
+        FD_ZERO(&rd);
+        FD_SET( oss, &rd );
+        struct timeval tv;
+        tv.tv_sec = 0;
+        tv.tv_usec = 0;
+        int returnCode = ::select( oss+1, &rd, NULL, NULL, &tv );
+        if( returnCode == -1 ){
+            throw IOException(
+                __FILE__, __LINE__,
+                SocketError::getErrorString().c_str() );
+        }
+        return (returnCode == 0) ? 0 : 1;
+
+    #else
+
+        return 0;
+
+    #endif /* HAVE_SELECT */
+
+#endif // !defined(HAVE_WINSOCK2_H)
+}
+
+////////////////////////////////////////////////////////////////////////////////
 void TcpSocket::close() throw( decaf::io::IOException ) {
 
     try{
+
+        this->closed = true;
+
         // Destroy the input stream.
         if( inputStream != NULL ){
             inputStream->close();
@@ -165,180 +400,237 @@ void TcpSocket::close() throw( decaf::io
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-int TcpSocket::getSoLinger() const throw( SocketException ){
+void TcpSocket::shutdownInput() throw( decaf::io::IOException ) {
 
-   try{
-        int value = 0;
-        checkResult( apr_socket_opt_get( socketHandle, APR_SO_LINGER, &value ) );
-        return value;
+    if( isClosed() ){
+        throw IOException(
+            __FILE__, __LINE__, "The stream is closed" );
     }
-    DECAF_CATCH_RETHROW( SocketException )
-    DECAF_CATCHALL_THROW( SocketException )
+
+    this->inputShutdown = true;
+    apr_socket_shutdown( socketHandle, APR_SHUTDOWN_READ );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void TcpSocket::setSoLinger( int dolinger ) throw( SocketException ){
+void TcpSocket::shutdownOutput() throw( decaf::io::IOException ) {
 
-    try{
-        checkResult( apr_socket_opt_set( socketHandle, APR_SO_LINGER, dolinger ) );
+    if( isClosed() ){
+        throw IOException(
+            __FILE__, __LINE__, "The stream is closed" );
     }
-    DECAF_CATCH_RETHROW( SocketException )
-    DECAF_CATCHALL_THROW( SocketException )
+
+    this->outputShutdown = true;
+    apr_socket_shutdown( socketHandle, APR_SHUTDOWN_WRITE );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-bool TcpSocket::getKeepAlive() const throw( SocketException ){
+int TcpSocket::getOption( int option ) const throw( decaf::io::IOException ) {
 
     try{
-        int value = 0;
-        checkResult( apr_socket_opt_get( socketHandle, APR_SO_KEEPALIVE, &value ) );
-        return value != 0;
-    }
-    DECAF_CATCH_RETHROW( SocketException )
-    DECAF_CATCHALL_THROW( SocketException )
-}
 
-////////////////////////////////////////////////////////////////////////////////
-void TcpSocket::setKeepAlive( const bool keepAlive ) throw( SocketException ){
+        if( isClosed() ) {
+            throw IOException(
+                __FILE__, __LINE__, "The Socket is closed." );
+        }
 
-    try{
-        int value = keepAlive ? 1 : 0;
-        checkResult( apr_socket_opt_set( socketHandle, APR_SO_KEEPALIVE, value ) );
-    }
-    DECAF_CATCH_RETHROW( SocketException )
-    DECAF_CATCHALL_THROW( SocketException )
-}
+        apr_int32_t aprId = 0;
+        apr_int32_t value = 0;
 
-////////////////////////////////////////////////////////////////////////////////
-int TcpSocket::getReceiveBufferSize() const throw( SocketException ){
+        if( option == SocketOptions::SOCKET_OPTION_TIMEOUT ) {
 
-    try{
-        int value;
-        checkResult( apr_socket_opt_get( socketHandle, APR_SO_RCVBUF, &value ) );
-        return value;
-    }
-    DECAF_CATCH_RETHROW( SocketException )
-    DECAF_CATCHALL_THROW( SocketException )
-}
+            // Time in APR on socket is stored in microseconds.
+            apr_interval_time_t tvalue = 0;
+            checkResult( apr_socket_timeout_get( socketHandle, &tvalue ) );
+            return (int)( tvalue / 1000 );
 
-////////////////////////////////////////////////////////////////////////////////
-void TcpSocket::setReceiveBufferSize( int size ) throw( SocketException ){
+        } else {
+        }
 
-    try{
-        checkResult( apr_socket_opt_set( socketHandle, APR_SO_RCVBUF, size ) );
+        checkResult( apr_socket_opt_get( socketHandle, aprId, &value ) );
+
+        return (int)value;
     }
-    DECAF_CATCH_RETHROW( SocketException )
-    DECAF_CATCHALL_THROW( SocketException )
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCHALL_THROW( IOException )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-bool TcpSocket::getReuseAddress() const throw( SocketException ){
+void TcpSocket::setOption( int option, int value ) throw( decaf::io::IOException ) {
 
     try{
-        int value;
-        checkResult( apr_socket_opt_get( socketHandle, APR_SO_REUSEADDR, &value ) );
-        return value != 0;
-    }
-    DECAF_CATCH_RETHROW( SocketException )
-    DECAF_CATCHALL_THROW( SocketException )
-}
 
-////////////////////////////////////////////////////////////////////////////////
-void TcpSocket::setReuseAddress( bool reuse ) throw( SocketException ){
+        if( isClosed() ) {
+            throw IOException(
+                __FILE__, __LINE__, "The Socket is closed." );
+        }
 
-    try{
-        int value = reuse ? 1 : 0;
-        checkResult( apr_socket_opt_set( socketHandle, APR_SO_REUSEADDR, value ) );
-    }
-    DECAF_CATCH_RETHROW( SocketException )
-    DECAF_CATCHALL_THROW( SocketException )
-}
+        apr_int32_t aprId = 0;
 
-////////////////////////////////////////////////////////////////////////////////
-int TcpSocket::getSendBufferSize() const throw( SocketException ){
+        if( option == SocketOptions::SOCKET_OPTION_TIMEOUT ) {
 
-    try{
-        int value;
-        checkResult( apr_socket_opt_get( socketHandle, APR_SO_SNDBUF, &value ) );
-        return value;
-    }
-    DECAF_CATCH_RETHROW( SocketException )
-    DECAF_CATCHALL_THROW( SocketException )
-}
+            // Time in APR for sockets is in microseconds so multiply by 1000.
+            checkResult( apr_socket_timeout_set( socketHandle, value * 1000 ) );
 
-////////////////////////////////////////////////////////////////////////////////
-void TcpSocket::setSendBufferSize( int size ) throw( SocketException ){
+        } else {
+        }
 
-    try{
-        checkResult( apr_socket_opt_set( socketHandle, APR_SO_SNDBUF, size ) );
+        checkResult( apr_socket_opt_set( socketHandle, aprId, (apr_int32_t)value ) );
     }
-    DECAF_CATCH_RETHROW( SocketException )
-    DECAF_CATCHALL_THROW( SocketException )
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCHALL_THROW( IOException )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void TcpSocket::setSoTimeout ( const int millisecs ) throw ( SocketException ) {
+void TcpSocket::checkResult( apr_status_t value ) const throw ( SocketException ) {
 
-    try{
-        // Time is in microseconds so multiply by 1000.
-        checkResult( apr_socket_timeout_set( socketHandle, millisecs * 1000 ) );
+    if( value != APR_SUCCESS ){
+        throw SocketException(
+            __FILE__, __LINE__,
+            SocketError::getErrorString().c_str() );
     }
-    DECAF_CATCH_RETHROW( SocketException )
-    DECAF_CATCHALL_THROW( SocketException )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-int TcpSocket::getSoTimeout() const throw( SocketException ) {
+int TcpSocket::read( unsigned char* buffer, int size, int offset, int length )
+    throw ( decaf::io::IOException,
+            decaf::lang::exceptions::IndexOutOfBoundsException,
+            decaf::lang::exceptions::NullPointerException ) {
 
     try{
-        // Time is in microseconds so divide by 1000.
-        apr_interval_time_t value = 0;
-        checkResult( apr_socket_timeout_get( socketHandle, &value ) );
-        return (int)( value / 1000 );
-    }
-    DECAF_CATCH_RETHROW( SocketException )
-    DECAF_CATCHALL_THROW( SocketException )
-}
+        if( this->isClosed() ){
+            throw IOException(
+                __FILE__, __LINE__,
+                "decaf::io::TcpSocketInputStream::read - The Stream has been closed" );
+        }
 
-////////////////////////////////////////////////////////////////////////////////
-bool TcpSocket::getTcpNoDelay() const throw ( lang::Exception ) {
+        if( this->inputShutdown == true ) {
+            return -1;
+        }
 
-    try{
-        int value;
-        checkResult( apr_socket_opt_get( socketHandle, APR_TCP_NODELAY, &value ) );
-        return value != 0;
+        if( length == 0 ) {
+            return 0;
+        }
+
+        if( buffer == NULL ) {
+            throw NullPointerException(
+                __FILE__, __LINE__,
+                "TcpSocketInputStream::read - Buffer passed is Null" );
+        }
+
+        if( size < 0 ) {
+            throw IndexOutOfBoundsException(
+                __FILE__, __LINE__, "size parameter out of Bounds: %d.", size );
+        }
+
+        if( offset > size || offset < 0 ) {
+            throw IndexOutOfBoundsException(
+                __FILE__, __LINE__, "offset parameter out of Bounds: %d.", offset );
+        }
+
+        if( length < 0 || length > size - offset ) {
+            throw IndexOutOfBoundsException(
+                __FILE__, __LINE__, "length parameter out of Bounds: %d.", length );
+        }
+
+        apr_size_t aprSize = (apr_size_t)length;
+        apr_status_t result = APR_SUCCESS;
+
+        // Read data from the socket, size on input is size of buffer, when done
+        // size is the number of bytes actually read, can be <= bufferSize.
+        result = apr_socket_recv( socketHandle, (char*)buffer + offset, &aprSize );
+
+        // Check for EOF, on windows we only get size==0 so check that to, if we
+        // were closed though then we throw an IOException so the caller knows we
+        // aren't usable anymore.
+        if( ( APR_STATUS_IS_EOF( result ) || aprSize == 0 ) && !closed ) {
+            this->inputShutdown = true;
+            return -1;
+        }
+
+        if( isClosed() ){
+            throw IOException(
+                __FILE__, __LINE__,
+                "decaf::io::TcpSocketInputStream::read - The connection is broken" );
+        }
+
+        if( result != APR_SUCCESS ){
+            throw IOException(
+                __FILE__, __LINE__,
+                "decaf::net::TcpSocketInputStream::read - %s",
+                SocketError::getErrorString().c_str() );
+        }
+
+        return (int)aprSize;
     }
-    DECAF_CATCH_RETHROW( SocketException )
-    DECAF_CATCHALL_THROW( SocketException )
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCH_RETHROW( NullPointerException )
+    DECAF_CATCH_RETHROW( IndexOutOfBoundsException )
+    DECAF_CATCHALL_THROW( IOException )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void TcpSocket::setTcpNoDelay( bool value ) throw ( lang::Exception ) {
+void TcpSocket::write( const unsigned char* buffer, int size, int offset, int length )
+    throw ( decaf::io::IOException,
+            decaf::lang::exceptions::IndexOutOfBoundsException,
+            decaf::lang::exceptions::NullPointerException ) {
 
     try{
-        int ivalue = value ? 1 : 0;
-        checkResult( apr_socket_opt_set( socketHandle, APR_TCP_NODELAY, ivalue ) );
-    }
-    DECAF_CATCH_RETHROW( SocketException )
-    DECAF_CATCHALL_THROW( SocketException )
-}
 
-////////////////////////////////////////////////////////////////////////////////
-void TcpSocket::setConnectTimeout( int timeout ) throw( decaf::net::SocketException ) {
-    this->connectTimeout = timeout;
-}
+        if( length == 0 ) {
+            return;
+        }
 
-////////////////////////////////////////////////////////////////////////////////
-int TcpSocket::getConnectTimeout() const throw( decaf::net::SocketException ) {
-    return this->connectTimeout;
-}
+        if( buffer == NULL ) {
+            throw NullPointerException(
+                __FILE__, __LINE__,
+                "TcpSocketOutputStream::write - passed buffer is null" );
+        }
 
-////////////////////////////////////////////////////////////////////////////////
-void TcpSocket::checkResult( apr_status_t value ) const throw ( SocketException ) {
+        if( closed ) {
+            throw IOException(
+                __FILE__, __LINE__,
+                "TcpSocketOutputStream::write - This Stream has been closed." );
+        }
 
-    if( value != APR_SUCCESS ){
-        throw SocketException(
-            __FILE__, __LINE__,
-            SocketError::getErrorString().c_str() );
+        if( size < 0 ) {
+            throw IndexOutOfBoundsException(
+                __FILE__, __LINE__, "size parameter out of Bounds: %d.", size );
+        }
+
+        if( offset > size || offset < 0 ) {
+            throw IndexOutOfBoundsException(
+                __FILE__, __LINE__, "offset parameter out of Bounds: %d.", offset );
+        }
+
+        if( length < 0 || length > size - offset ) {
+            throw IndexOutOfBoundsException(
+                __FILE__, __LINE__, "length parameter out of Bounds: %d.", length );
+        }
+
+        apr_size_t remaining = (apr_size_t)length;
+        apr_status_t result = APR_SUCCESS;
+
+        const unsigned char* lbuffer = buffer + offset;
+
+        while( remaining > 0 && !closed ) {
+            // On input remaining is the bytes to send, after return remaining
+            // is the amount actually sent.
+            result = apr_socket_send( socketHandle, (const char*)lbuffer, &remaining );
+
+            if( result != APR_SUCCESS || closed ) {
+                throw IOException(
+                    __FILE__, __LINE__,
+                    "decaf::net::TcpSocketOutputStream::write - %s",
+                    SocketError::getErrorString().c_str() );
+            }
+
+            // move us to next position to write, or maybe end.
+            lbuffer += remaining;
+            remaining = length - remaining;
+        }
     }
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCH_RETHROW( NullPointerException )
+    DECAF_CATCH_RETHROW( IndexOutOfBoundsException )
+    DECAF_CATCHALL_THROW( IOException )
 }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.h?rev=932637&r1=932636&r2=932637&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.h Fri Apr  9 22:17:38 2010
@@ -18,12 +18,18 @@
 #define _DECAF_INTERNAL_NET_TCP_TCPSOCKET_H_
 
 #include <decaf/net/SocketException.h>
-#include <decaf/net/Socket.h>
+#include <decaf/net/SocketImpl.h>
 #include <decaf/io/InputStream.h>
 #include <decaf/io/OutputStream.h>
 #include <decaf/util/Config.h>
 #include <decaf/internal/AprPool.h>
 
+#include <apr_network_io.h>
+
+#include <decaf/io/IOException.h>
+#include <decaf/lang/exceptions/NullPointerException.h>
+#include <decaf/lang/exceptions/IndexOutOfBoundsException.h>
+
 namespace decaf {
 namespace internal {
 namespace net {
@@ -36,7 +42,19 @@ namespace tcp {
     /**
      * Platform-independent implementation of the socket interface.
      */
-    class DECAF_API TcpSocket : public decaf::net::Socket {
+    class DECAF_API TcpSocket : public decaf::net::SocketImpl {
+    private:
+
+        /**
+         * Define the SocketHandle type.
+         */
+        typedef apr_socket_t* SocketHandle;
+
+        /**
+         * Define the SocketAddress type
+         */
+        typedef apr_sockaddr_t* SocketAddress;
+
     private:
 
         /**
@@ -47,12 +65,17 @@ namespace tcp {
         /**
          * The handle for this socket.
          */
-        decaf::net::Socket::SocketHandle socketHandle;
+        SocketHandle socketHandle;
 
         /**
-         * The Address info for this Socket
+         * Address of the locally bound portion of the Socket.
          */
-        decaf::net::Socket::SocketAddress socketAddress;
+        SocketAddress localAddress;
+
+        /**
+         * Address of the remoute connection portion of the Socket.
+         */
+        SocketAddress remoteAddress;
 
         /**
          * The input stream for reading this socket.
@@ -65,9 +88,24 @@ namespace tcp {
         TcpSocketOutputStream* outputStream;
 
         /**
-         * Configured Connect Timeout, -1 means no timeout.
+         * Was input already shutdown on this Socket.
+         */
+        bool inputShutdown;
+
+        /**
+         * Was output already shutdown on this Socket.
          */
-        int connectTimeout;
+        bool outputShutdown;
+
+        /**
+         * Was the Socket closed.
+         */
+        volatile bool closed;
+
+        /**
+         * Current Traffic class setting.
+         */
+        int trafficClass;
 
     public:
 
@@ -79,13 +117,6 @@ namespace tcp {
         TcpSocket() throw ( decaf::net::SocketException );
 
         /**
-         * Construct a connected or bound socket based on given
-         * socket handle.
-         * @param socketHandle a socket handle to wrap in the object
-         */
-        TcpSocket( decaf::net::Socket::SocketHandle socketHandle );
-
-        /**
          * Releases the socket handle but not gracefully shut down the connection.
          */
         virtual ~TcpSocket();
@@ -94,166 +125,144 @@ namespace tcp {
          * Gets the handle for the socket.
          * @return SocketHabler for this Socket, can be NULL
          */
-        decaf::net::Socket::SocketHandle getSocketHandle () {
+        SocketHandle getSocketHandle () {
             return socketHandle;
         }
 
         /**
-         * Connects to the specified destination. Closes this socket if
-         * connected to another destination.
-         * @param host The host of the server to connect to.
-         * @param port The port of the server to connect to.
-         * @throws SocketException Thrown if a failure occurred in the connect.
+         * @returns true if the socketHandle is not in a disconnected state.
          */
-        virtual void connect( const char* host, int port )
-            throw( decaf::net::SocketException );
-
-        /**
-         * Indicates whether or not this socket is connected to a destination.
-         * @return true if connected
-         */
-        virtual bool isConnected() const{
+        bool isConnected() const {
             return socketHandle != NULL;
         }
 
         /**
-         * Gets the InputStream for this socket.
-         * @return The InputStream for this socket. NULL if not connected.
+         * @returns true if the close method has been called on this Socket.
          */
-        virtual io::InputStream* getInputStream();
-
-        /**
-         * Gets the OutputStream for this socket.
-         * @return the OutputStream for this socket.  NULL if not connected.
-         */
-        virtual io::OutputStream* getOutputStream();
+        bool isClosed() const {
+            return this->closed;
+        }
 
         /**
-         * Gets the linger time.
-         * @return The linger time in seconds.
-         * @throws SocketException if the operation fails.
+         * {@inheritDoc}
          */
-        virtual int getSoLinger() const throw( decaf::net::SocketException );
+        virtual std::string getLocalAddress() const;
 
         /**
-         * Sets the linger time.
-         * @param linger The linger time in seconds.  If 0, linger is off.
-         * @throws SocketException if the operation fails.
+         * {@inheritDoc}
          */
-        virtual void setSoLinger( int linger ) throw( decaf::net::SocketException );
+        virtual void create() throw( decaf::io::IOException );
 
         /**
-         * Gets the keep alive flag.
-         * @return True if keep alive is enabled.
-         * @throws SocketException if the operation fails.
+         * {@inheritDoc}
          */
-        virtual bool getKeepAlive() const throw( decaf::net::SocketException );
+        virtual void accept( SocketImpl* socket ) throw( decaf::io::IOException );
 
         /**
-         * Enables/disables the keep alive flag.
-         * @param keepAlive If true, enables the flag.
-         * @throws SocketException if the operation fails.
+         * {@inheritDoc}
          */
-        virtual void setKeepAlive( bool keepAlive ) throw( decaf::net::SocketException );
+        virtual void bind( const std::string& ipaddress, int port )
+            throw( decaf::io::IOException );
 
         /**
-         * Gets the receive buffer size.
-         * @return the receive buffer size in bytes.
-         * @throws SocketException if the operation fails.
+         * {@inheritDoc}
          */
-        virtual int getReceiveBufferSize() const throw( decaf::net::SocketException );
+        virtual void connect( const std::string& hostname, int port, int timeout )
+            throw( decaf::io::IOException,
+                   decaf::lang::exceptions::IllegalArgumentException );
 
         /**
-         * Sets the recieve buffer size.
-         * @param size Number of bytes to set the receive buffer to.
-         * @throws SocketException if the operation fails.
+         * {@inheritDoc}
          */
-        virtual void setReceiveBufferSize( int size ) throw( decaf::net::SocketException );
+        virtual void listen( int backlog ) throw( decaf::io::IOException );
 
         /**
-         * Gets the reuse address flag.
-         * @return True if the address can be reused.
-         * @throws SocketException if the operation fails.
+         * {@inheritDoc}
          */
-        virtual bool getReuseAddress() const throw( decaf::net::SocketException );
+        virtual decaf::io::InputStream* getInputStream()
+            throw( decaf::io::IOException );
 
         /**
-         * Sets the reuse address flag.
-         * @param reuse If true, sets the flag.
-         * @throws SocketException if the operation fails.
+         * {@inheritDoc}
          */
-        virtual void setReuseAddress( bool reuse ) throw( decaf::net::SocketException );
+        virtual decaf::io::OutputStream* getOutputStream()
+            throw( decaf::io::IOException );
 
         /**
-         * Gets the send buffer size.
-         * @return the size in bytes of the send buffer.
-         * @throws SocketException if the operation fails.
+         * {@inheritDoc}
          */
-        virtual int getSendBufferSize() const throw( decaf::net::SocketException );
+        virtual int available() throw( decaf::io::IOException );
 
         /**
-         * Sets the send buffer size.
-         * @param size The number of bytes to set the send buffer to.
-         * @throws SocketException if the operation fails.
+         * {@inheritDoc}
          */
-        virtual void setSendBufferSize( int size ) throw( decaf::net::SocketException );
+        virtual void close() throw( decaf::io::IOException );
 
         /**
-         * Gets the timeout for socket operations.
-         * @return The timeout in milliseconds for socket operations.
-         * @throws SocketException Thrown if unable to retrieve the information.
+         * {@inheritDoc}
          */
-        virtual int getSoTimeout() const throw( decaf::net::SocketException );
+        virtual void shutdownInput() throw( decaf::io::IOException );
 
         /**
-         * Sets the timeout for socket operations.
-         * @param timeout The timeout in milliseconds for socket operations.<p>
-         * @throws SocketException Thrown if unable to set the information.
+         * {@inheritDoc}
          */
-        virtual void setSoTimeout( int timeout ) throw( decaf::net::SocketException );
+        virtual void shutdownOutput() throw( decaf::io::IOException );
 
         /**
-         * Closes this object and deallocates the appropriate resources.
-         * @throws IOException
+         * {@inheritDoc}
          */
-        virtual void close() throw( decaf::io::IOException );
+        virtual int getOption( int option ) const throw( decaf::io::IOException );
 
         /**
-         * Gets the Status of the TCP_NODELAY param for this socket as a Bool
-         * @returns true if TCP_NODELAY is enabled
-         * @throws Exception
+         * {@inheritDoc}
          */
-        virtual bool getTcpNoDelay() const throw ( decaf::lang::Exception );
+        virtual void setOption( int option, int value ) throw( decaf::io::IOException );
 
-        /**
-         * Sets the Status of the TCP_NODELAY param for this socket as a Bool
-         * @param value - true if TCP_NODELAY is to be enabled
-         * @throws Exception
-         */
-        virtual void setTcpNoDelay( bool value ) throw ( decaf::lang::Exception );
+    public:
 
         /**
-         * Gets the set Connect timeout, Socket implementations that support this
-         * setting will throw an SocketException if they cannot connect within the
-         * specified timeout.
+         * Reads the requested data from the Socket and write it into the passed in buffer.
          *
-         * @returns The time in Milliseconds to wait for a connection to be made.
+         * @param buffer
+         *      The buffer to read into
+         * @param size
+         *      The size of the specified buffer
+         * @param offset
+         *      The offset into the buffer where reading should start filling.
+         * @param length
+         *      The number of bytes past offset to fill with data.
          *
-         * @throws SocketException if the operation fails.
+         * @return the actual number of bytes read or -1 if at EOF.
+         *
+         * @throw IOException if an I/O error occurs during the read.
+         * @throw NullPointerException if buffer is Null.
+         * @throw IndexOutOfBoundsException if offset + length is greater than buffer size.
          */
-        virtual int getConnectTimeout() const throw( decaf::net::SocketException );
+        int read( unsigned char* buffer, int size, int offset, int length )
+            throw ( decaf::io::IOException,
+                    decaf::lang::exceptions::IndexOutOfBoundsException,
+                    decaf::lang::exceptions::NullPointerException );
 
         /**
-         * Sets the set Connect timeout, Socket implementations that support this
-         * setting will throw an SocketException if they cannot connect within the
-         * specified timeout.
+         * Writes the specified data in the passed in buffer to the Socket.
          *
-         * @param timeout
-         *      The time in Milliseconds to wait for a connection to be made.
+         * @param buffer
+         *      The buffer to write to the socket.
+         * @param size
+         *      The size of the specified buffer.
+         * @param offset
+         *      The offset into the buffer where the data to write starts at.
+         * @param length
+         *      The number of bytes past offset to write.
          *
-         * @throws SocketException if the operation fails.
-         */
-        virtual void setConnectTimeout( int timeout ) throw( decaf::net::SocketException );
+         * @throw IOException if an I/O error occurs during the write.
+         * @throw NullPointerException if buffer is Null.
+         * @throw IndexOutOfBoundsException if offset + length is greater than buffer size.
+         */
+        void write( const unsigned char* buffer, int size, int offset, int length )
+            throw ( decaf::io::IOException,
+                    decaf::lang::exceptions::IndexOutOfBoundsException,
+                    decaf::lang::exceptions::NullPointerException );
 
     protected:
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocketInputStream.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocketInputStream.cpp?rev=932637&r1=932636&r2=932637&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocketInputStream.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocketInputStream.cpp Fri Apr  9 22:17:38 2010
@@ -15,38 +15,11 @@
  * limitations under the License.
  */
 
-#include <decaf/util/Config.h>
-
-#if !defined(HAVE_WINSOCK2_H)
-    #include <sys/select.h>
-    #include <sys/socket.h>
-#else
-    #include <Winsock2.h>
-#endif
-
-#ifdef HAVE_SYS_IOCTL_H
-#define BSD_COMP /* Get FIONREAD on Solaris2. */
-#include <sys/ioctl.h>
-#include <unistd.h>
-#endif
-
-// Pick up FIONREAD on Solaris 2.5.
-#ifdef HAVE_SYS_FILIO_H
-#include <sys/filio.h>
-#endif
-
 #include <decaf/internal/net/tcp/TcpSocketInputStream.h>
-#include <decaf/net/SocketError.h>
+
 #include <decaf/net/Socket.h>
 #include <decaf/io/IOException.h>
-#include <decaf/lang/Character.h>
-#include <decaf/lang/exceptions/UnsupportedOperationException.h>
-#include <stdlib.h>
-#include <string>
-#include <stdio.h>
-#include <iostream>
-
-#include <apr_portable.h>
+#include <decaf/internal/net/tcp/TcpSocket.h>
 
 using namespace decaf;
 using namespace decaf::net;
@@ -60,107 +33,53 @@ using namespace decaf::lang::exceptions;
 using namespace std;
 
 ////////////////////////////////////////////////////////////////////////////////
-TcpSocketInputStream::TcpSocketInputStream( decaf::net::Socket::SocketHandle socket ) : InputStream() {
-    this->socket = socket;
-    this->closed = false;
+TcpSocketInputStream::TcpSocketInputStream( TcpSocket* socket ) :
+    InputStream(), socket( socket ), closed( false ) {
+
+    if( socket == NULL ) {
+        throw NullPointerException(
+            __FILE__, __LINE__, "TcpSocket instance passed was NULL." );
+    }
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-TcpSocketInputStream::~TcpSocketInputStream(){}
+TcpSocketInputStream::~TcpSocketInputStream() {
+}
 
 ////////////////////////////////////////////////////////////////////////////////
-void TcpSocketInputStream::close() throw( decaf::io::IOException ){
+void TcpSocketInputStream::close() throw( decaf::io::IOException ) {
     this->closed = true;
+    this->socket->close();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 int TcpSocketInputStream::available() const throw ( io::IOException ){
 
-    // Check for a closed call from socket class, if closed then this read fails.
-    if( closed ){
+    if( this->closed ){
         throw IOException(
-            __FILE__, __LINE__,
-            "decaf::io::TcpSocketInputStream::available - The stream is closed" );
-    }
-
-    // Convert to an OS level socket.
-    apr_os_sock_t oss;
-    apr_os_sock_get( (apr_os_sock_t*)&oss, socket );
-
-// The windows version
-#if defined(HAVE_WINSOCK2_H)
-
-    unsigned long numBytes = 0;
-
-    if( ::ioctlsocket( oss, FIONREAD, &numBytes ) == SOCKET_ERROR ){
-        throw SocketException( __FILE__, __LINE__, "ioctlsocket failed" );
+            __FILE__, __LINE__, "The stream is closed" );
     }
 
-    return numBytes;
-
-#else // !defined(HAVE_WINSOCK2_H)
-
-    // If FIONREAD is defined - use ioctl to find out how many bytes
-    // are available.
-    #if defined(FIONREAD)
-
-        int numBytes = 0;
-        if( ::ioctl( oss, FIONREAD, &numBytes ) != -1 ){
-            return numBytes;
-        }
-
-    #endif
-
-    // If we didn't get anything we can use select.  This is a little
-    // less functional.  We will poll on the socket - if there is data
-    // available, we'll return 1, otherwise we'll return zero.
-    #if defined(HAVE_SELECT)
-
-        fd_set rd;
-        FD_ZERO(&rd);
-        FD_SET( oss, &rd );
-        struct timeval tv;
-        tv.tv_sec = 0;
-        tv.tv_usec = 0;
-        int returnCode = ::select( oss+1, &rd, NULL, NULL, &tv );
-        if( returnCode == -1 ){
-            throw IOException(
-                __FILE__, __LINE__,
-                SocketError::getErrorString().c_str() );
-        }
-        return (returnCode == 0) ? 0 : 1;
-
-    #else
-
-        return 0;
-
-    #endif /* HAVE_SELECT */
-
-#endif // !defined(HAVE_WINSOCK2_H)
+    return this->socket->available();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 int TcpSocketInputStream::doReadByte() throw ( IOException ){
 
-    // Check for a closed call from socket class, if closed then this read fails.
-    if( closed ){
+    if( this->closed ){
         throw IOException(
-            __FILE__, __LINE__,
-            "decaf::io::TcpSocketInputStream::read - The Stream has been closed" );
+            __FILE__, __LINE__, "The stream is closed" );
     }
 
-    apr_status_t result = APR_SUCCESS;
-    char c;
-    apr_size_t size = 1;
-
-    result = apr_socket_recv( socket, &c, &size );
+    try{
 
-    if( ( size != sizeof(c) && !closed ) || result != APR_SUCCESS ){
-        throw IOException( __FILE__, __LINE__,
-            "activemq::io::TcpSocketInputStream::read - failed reading a byte");
+        unsigned char buffer[1];
+        int result = this->socket->read( buffer, 1, 0, 1 );
+        return result == -1 ? result : buffer[0];
     }
-
-    return c;
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCH_EXCEPTION_CONVERT( Exception, IOException )
+    DECAF_CATCHALL_THROW( IOException )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -169,75 +88,40 @@ int TcpSocketInputStream::doReadArrayBou
             decaf::lang::exceptions::IndexOutOfBoundsException,
             decaf::lang::exceptions::NullPointerException ) {
 
-    // Check for a closed call from socket class, if closed then this read fails.
     if( closed ){
         throw IOException(
-            __FILE__, __LINE__,
-            "decaf::io::TcpSocketInputStream::read - The Stream has been closed" );
-    }
-
-    if( length == 0 ) {
-        return 0;
+            __FILE__, __LINE__, "The stream is closed" );
     }
 
     if( buffer == NULL ) {
         throw NullPointerException(
-            __FILE__, __LINE__,
-            "TcpSocketInputStream::read - Buffer passed is Null" );
+            __FILE__, __LINE__, "Buffer passed was NULL." );
     }
 
-    if( size < 0 ) {
-        throw IndexOutOfBoundsException(
-            __FILE__, __LINE__, "size parameter out of Bounds: %d.", size );
+    try{
+        return this->socket->read( buffer, size, offset, length );
     }
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCH_RETHROW( IndexOutOfBoundsException )
+    DECAF_CATCH_RETHROW( NullPointerException )
+    DECAF_CATCH_EXCEPTION_CONVERT( Exception, IOException )
+    DECAF_CATCHALL_THROW( IOException )
+}
 
-    if( offset > size || offset < 0 ) {
-        throw IndexOutOfBoundsException(
-            __FILE__, __LINE__, "offset parameter out of Bounds: %d.", offset );
-    }
-
-    if( length < 0 || length > size - offset ) {
-        throw IndexOutOfBoundsException(
-            __FILE__, __LINE__, "length parameter out of Bounds: %d.", length );
-    }
-
-    apr_size_t aprSize = (apr_size_t)length;
-    apr_status_t result = APR_SUCCESS;
-
-    // Read data from the socket, size on input is size of buffer, when done
-    // size is the number of bytes actually read, can be <= bufferSize.
-    result = apr_socket_recv( socket, (char*)buffer + offset, &aprSize );
+////////////////////////////////////////////////////////////////////////////////
+long long TcpSocketInputStream::skip( long long num )
+    throw ( IOException, UnsupportedOperationException ) {
 
-    // Check for EOF, on windows we only get size==0 so check that to, if we
-    // were closed though then we throw an IOException so the caller knows we
-    // aren't usable anymore.
-    if( ( APR_STATUS_IS_EOF( result ) || aprSize == 0 ) && !closed ) {
-        return -1;
-    }
+    try{
 
-    // Check for a closed call from socket class, if closed then this read fails.
-    if( closed ){
-        throw IOException(
-            __FILE__, __LINE__,
-            "decaf::io::TcpSocketInputStream::read - The connection is broken" );
-    }
+        if( num == 0 ) {
+            return 0;
+        }
 
-    // Check for error.
-    if( result != APR_SUCCESS ){
-        throw IOException(
-            __FILE__, __LINE__,
-            "decaf::net::TcpSocketInputStream::read - %s",
-            SocketError::getErrorString().c_str() );
+        return InputStream::skip( num );
     }
-
-    return (int)aprSize;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-long long TcpSocketInputStream::skip( long long num DECAF_UNUSED )
-    throw ( io::IOException, lang::exceptions::UnsupportedOperationException ) {
-
-    throw lang::exceptions::UnsupportedOperationException(
-        __FILE__, __LINE__,
-        "TcpSocketInputStream::skip() method is not supported");
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCH_RETHROW( UnsupportedOperationException )
+    DECAF_CATCH_EXCEPTION_CONVERT( Exception, IOException )
+    DECAF_CATCHALL_THROW( IOException )
 }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocketInputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocketInputStream.h?rev=932637&r1=932636&r2=932637&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocketInputStream.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocketInputStream.h Fri Apr  9 22:17:38 2010
@@ -18,16 +18,20 @@
 #ifndef _DECAF_INTERNAL_NET_TCP_TCPSOCKETINPUTSTREAM_H_
 #define _DECAF_INTERNAL_NET_TCP_TCPSOCKETINPUTSTREAM_H_
 
+#include <decaf/util/Config.h>
+
 #include <decaf/io/InputStream.h>
-#include <decaf/net/Socket.h>
-#include <decaf/lang/Exception.h>
+#include <decaf/io/IOException.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <decaf/lang/exceptions/IndexOutOfBoundsException.h>
 
 namespace decaf {
 namespace internal {
 namespace net {
 namespace tcp {
 
+    class TcpSocket;
+
     /**
      * Input stream for performing reads on a socket.  This class will only
      * work properly for blocking sockets.
@@ -37,16 +41,19 @@ namespace tcp {
     class DECAF_API TcpSocketInputStream : public decaf::io::InputStream {
     private:
 
-        decaf::net::Socket::SocketHandle socket;
+        TcpSocket* socket;
+
         bool closed;
 
     public:
 
         /**
-         * Constructor.
-         * @param socket the socket handle.
+         * Create a new InputStream to use for reading from the TCP/IP socket.
+         *
+         * @param socket
+         *      The parent SocketImpl for this stream.
          */
-        TcpSocketInputStream( decaf::net::Socket::SocketHandle socket );
+        TcpSocketInputStream( TcpSocket* socket );
 
         virtual ~TcpSocketInputStream();
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocketOutputStream.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocketOutputStream.cpp?rev=932637&r1=932636&r2=932637&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocketOutputStream.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocketOutputStream.cpp Fri Apr  9 22:17:38 2010
@@ -21,6 +21,8 @@
 
 #include <decaf/net/SocketError.h>
 
+#include <decaf/internal/net/tcp/TcpSocket.h>
+
 using namespace decaf;
 using namespace decaf::net;
 using namespace decaf::io;
@@ -33,23 +35,27 @@ using namespace decaf::lang::exceptions;
 using namespace std;
 
 ////////////////////////////////////////////////////////////////////////////////
-TcpSocketOutputStream::TcpSocketOutputStream( decaf::net::Socket::SocketHandle socket ) {
-    this->socket = socket;
-    this->closed = false;
+TcpSocketOutputStream::TcpSocketOutputStream( TcpSocket* socket ) :
+    OutputStream(), socket( socket ), closed( false ) {
+
+    if( socket == NULL ) {
+        throw NullPointerException(
+            __FILE__, __LINE__, "TcpSocket instance passed was NULL." );
+    }
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 TcpSocketOutputStream::~TcpSocketOutputStream() {
-    try{
-        this->close();
-    }
-    DECAF_CATCH_NOTHROW( Exception )
-    DECAF_CATCHALL_NOTHROW()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 void TcpSocketOutputStream::close() throw( decaf::io::IOException ) {
-    this->closed = true;
+    try{
+        this->closed = true;
+        this->socket->close();
+    }
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCHALL_THROW( IOException )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -88,42 +94,7 @@ void TcpSocketOutputStream::doWriteArray
                 "TcpSocketOutputStream::write - This Stream has been closed." );
         }
 
-        if( size < 0 ) {
-            throw IndexOutOfBoundsException(
-                __FILE__, __LINE__, "size parameter out of Bounds: %d.", size );
-        }
-
-        if( offset > size || offset < 0 ) {
-            throw IndexOutOfBoundsException(
-                __FILE__, __LINE__, "offset parameter out of Bounds: %d.", offset );
-        }
-
-        if( length < 0 || length > size - offset ) {
-            throw IndexOutOfBoundsException(
-                __FILE__, __LINE__, "length parameter out of Bounds: %d.", length );
-        }
-
-        apr_size_t remaining = (apr_size_t)length;
-        apr_status_t result = APR_SUCCESS;
-
-        const unsigned char* lbuffer = buffer + offset;
-
-        while( remaining > 0 && !closed ) {
-            // On input remaining is the bytes to send, after return remaining
-            // is the amount actually sent.
-            result = apr_socket_send( socket, (const char*)lbuffer, &remaining );
-
-            if( result != APR_SUCCESS || closed ) {
-                throw IOException(
-                    __FILE__, __LINE__,
-                    "decaf::net::TcpSocketOutputStream::write - %s",
-                    SocketError::getErrorString().c_str() );
-            }
-
-            // move us to next position to write, or maybe end.
-            lbuffer += remaining;
-            remaining = length - remaining;
-        }
+        this->socket->write( buffer, size, offset, length );
     }
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCH_RETHROW( NullPointerException )

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocketOutputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocketOutputStream.h?rev=932637&r1=932636&r2=932637&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocketOutputStream.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocketOutputStream.h Fri Apr  9 22:17:38 2010
@@ -18,14 +18,17 @@
 #ifndef _DECAF_INTERNAL_NET_TCP_TCPSOCKETOUTPUTSTREAM_H_
 #define _DECAF_INTERNAL_NET_TCP_TCPSOCKETOUTPUTSTREAM_H_
 
+#include <decaf/util/Config.h>
+
 #include <decaf/io/OutputStream.h>
-#include <decaf/net/Socket.h>
 
 namespace decaf {
 namespace internal {
 namespace net {
 namespace tcp {
 
+    class TcpSocket;
+
     /**
      * Output stream for performing write operations on a socket.
      *
@@ -34,7 +37,7 @@ namespace tcp {
     class DECAF_API TcpSocketOutputStream : public decaf::io::OutputStream {
     private:
 
-        decaf::net::Socket::SocketHandle socket;
+        TcpSocket* socket;
         volatile bool closed;
 
     public:
@@ -43,9 +46,9 @@ namespace tcp {
          * Create a new instance of a Socket OutputStream class.
          *
          * @param socket
-         *      The socket handle to use to write out the data.
+         *      The socket to use to write out the data.
          */
-        TcpSocketOutputStream( decaf::net::Socket::SocketHandle socket );
+        TcpSocketOutputStream( TcpSocket* socket );
 
         virtual ~TcpSocketOutputStream();
 

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet4Address.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet4Address.cpp?rev=932637&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet4Address.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet4Address.cpp Fri Apr  9 22:17:38 2010
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "Inet4Address.h"
+
+using namespace decaf;
+using namespace decaf::net;
+
+////////////////////////////////////////////////////////////////////////////////
+Inet4Address::Inet4Address() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Inet4Address::~Inet4Address() {
+}

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet4Address.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet4Address.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet4Address.h?rev=932637&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet4Address.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet4Address.h Fri Apr  9 22:17:38 2010
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _DECAF_NET_INET4ADDRESS_H_
+#define _DECAF_NET_INET4ADDRESS_H_
+
+#include <decaf/util/Config.h>
+
+#include <decaf/net/InetAddress.h>
+
+namespace decaf {
+namespace net {
+
+    class DECAF_API Inet4Address : public InetAddress {
+    public:
+
+        Inet4Address();
+
+        virtual ~Inet4Address();
+
+    };
+
+}}
+
+#endif /* _DECAF_NET_INET4ADDRESS_H_ */

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet4Address.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet6Address.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet6Address.cpp?rev=932637&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet6Address.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet6Address.cpp Fri Apr  9 22:17:38 2010
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "Inet6Address.h"
+
+using namespace decaf;
+using namespace decaf::net;
+
+////////////////////////////////////////////////////////////////////////////////
+Inet6Address::Inet6Address() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Inet6Address::~Inet6Address() {
+}

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet6Address.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet6Address.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet6Address.h?rev=932637&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet6Address.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet6Address.h Fri Apr  9 22:17:38 2010
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _DECAF_API_INET6ADDRESS_H_
+#define _DECAF_API_INET6ADDRESS_H_
+
+#include <decaf/util/Config.h>
+
+#include <decaf/net/InetAddress.h>
+
+namespace decaf {
+namespace net {
+
+    class DECAF_API Inet6Address : public InetAddress {
+    public:
+
+        Inet6Address();
+
+        virtual ~Inet6Address();
+
+    };
+
+}}
+
+#endif /* _DECAF_API_INET6ADDRESS_H_ */

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet6Address.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/InetAddress.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/InetAddress.cpp?rev=932637&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/InetAddress.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/InetAddress.cpp Fri Apr  9 22:17:38 2010
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "InetAddress.h"
+
+using namespace decaf;
+using namespace decaf::net;
+using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
+
+////////////////////////////////////////////////////////////////////////////////
+const unsigned char InetAddress::loopbackBytes[4] = { 127, 0, 0, 1 };
+const unsigned char InetAddress::anyBytes[4] = { 0, 0, 0, 0 };
+
+////////////////////////////////////////////////////////////////////////////////
+InetAddress::InetAddress() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+InetAddress::InetAddress( unsigned char* ipAddress DECAF_UNUSED, int numBytes DECAF_UNUSED ) {
+
+    if( ipAddress == NULL ) {
+        throw NullPointerException(
+            __FILE__, __LINE__, "InetAddress constructor called with null address array." );
+    }
+
+    if( numBytes < 0 ) {
+        throw IllegalArgumentException(
+            __FILE__, __LINE__, "Number of bytes value is invalid: %d", numBytes );
+    }
+
+
+}
+
+////////////////////////////////////////////////////////////////////////////////
+InetAddress::InetAddress( const std::string& hostname DECAF_UNUSED, unsigned char* ipAddress DECAF_UNUSED, int numBytes DECAF_UNUSED ) {
+
+}
+
+////////////////////////////////////////////////////////////////////////////////
+InetAddress::~InetAddress() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+ArrayPointer<unsigned char> InetAddress::getAddress() const {
+
+    return ArrayPointer<unsigned char>();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string InetAddress::getHostAddress() const {
+
+    return "";
+}

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/InetAddress.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/InetAddress.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/InetAddress.h?rev=932637&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/InetAddress.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/InetAddress.h Fri Apr  9 22:17:38 2010
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _DECAF_NET_INETADDRESS_H_
+#define _DECAF_NET_INETADDRESS_H_
+
+#include <decaf/util/Config.h>
+
+#include <decaf/lang/ArrayPointer.h>
+
+namespace decaf {
+namespace net {
+
+    /**
+     * Represents an IP address.
+     *
+     * @since 1.0
+     */
+    class DECAF_API InetAddress {
+    protected:
+
+        static const unsigned char loopbackBytes[4];
+        static const unsigned char anyBytes[4];
+
+        static const InetAddress ANY;
+        static const InetAddress LOOPBACK;
+
+    private:
+
+        std::string hostname;
+        bool reached;
+        decaf::lang::ArrayPointer<unsigned char> addressBytes;
+
+    protected:
+
+        int family;
+
+    protected:
+
+        InetAddress();
+        InetAddress( unsigned char* ipAddress, int numBytes );
+        InetAddress( const std::string& hostname, unsigned char* ipAddress, int numBytes );
+
+    private:
+
+        InetAddress( const InetAddress& );
+        InetAddress& operator= ( const InetAddress& );
+
+    public:
+
+        virtual ~InetAddress();
+
+        /**
+         * Returns the Raw IP address in Network byte order.  The returned address is a copy
+         * of the bytes contained in this InetAddress.
+         *
+         * @returns and ArrayPointer containing the raw bytes of the network address.
+         */
+        decaf::lang::ArrayPointer<unsigned char> getAddress() const;
+
+        /**
+         * Returns a textual representation of the IP Address.
+         *
+         * @returns the string form of the IP Adrress.
+         */
+        std::string getHostAddress() const;
+
+    };
+
+}}
+
+#endif /* _DECAF_NET_INETADDRESS_H_ */

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/InetAddress.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/InetSocketAddress.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/InetSocketAddress.cpp?rev=932637&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/InetSocketAddress.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/InetSocketAddress.cpp Fri Apr  9 22:17:38 2010
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "InetSocketAddress.h"
+
+using namespace decaf;
+using namespace decaf::net;
+
+////////////////////////////////////////////////////////////////////////////////
+InetSocketAddress::InetSocketAddress() : SocketAddress() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+InetSocketAddress::~InetSocketAddress() {
+}

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/InetSocketAddress.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/InetSocketAddress.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/InetSocketAddress.h?rev=932637&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/InetSocketAddress.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/InetSocketAddress.h Fri Apr  9 22:17:38 2010
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _DECAF_NET_INETSOCKETADDRESS_H_
+#define _DECAF_NET_INETSOCKETADDRESS_H_
+
+#include <decaf/util/Config.h>
+
+#include <decaf/net/SocketAddress.h>
+
+#include <string>
+
+namespace decaf {
+namespace net {
+
+    class DECAF_API InetSocketAddress : public SocketAddress {
+    public:
+
+        InetSocketAddress();
+
+        virtual ~InetSocketAddress();
+
+    };
+
+}}
+
+#endif /* _DECAF_NET_INETSOCKETADDRESS_H_ */

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/InetSocketAddress.h
------------------------------------------------------------------------------
    svn:eol-style = native