activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nmitt...@apache.org
Subject svn commit: r424272 [6/10] - in /incubator/activemq/trunk/activemq-cpp: ./ src/examples/ src/main/activemq/concurrent/ src/main/activemq/connector/ src/main/activemq/connector/stomp/ src/main/activemq/connector/stomp/commands/ src/main/activemq/connect...
Date Fri, 21 Jul 2006 11:36:16 GMT
Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/io/EndianWriter.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/io/EndianWriter.cpp?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/io/EndianWriter.cpp (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/io/EndianWriter.cpp Fri Jul 21 04:36:09 2006
@@ -35,43 +35,41 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 EndianWriter::~EndianWriter()
-{
-    // no-op
-}
+{}
 
 ////////////////////////////////////////////////////////////////////////////////
-void EndianWriter::writeByte(unsigned char value) throw(IOException)
+void EndianWriter::writeByte( unsigned char value ) throw( IOException )
 {
     // Write a single byte
-    write(&value, sizeof(unsigned char));
+    write( &value, sizeof(unsigned char) );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void EndianWriter::writeDouble(double v) throw(IOException)
+void EndianWriter::writeDouble( double v ) throw( IOException )
 {
     // Write a double, byteswap if necessary
     double value = Endian::byteSwap(v);
-    write((unsigned char*)&value, sizeof(value));
+    write( (unsigned char*)&value, sizeof(value) );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void EndianWriter::writeFloat(float v) throw(IOException)
+void EndianWriter::writeFloat( float v ) throw( IOException )
 {
     // Write a float, byteswap if necessary
     float value = Endian::byteSwap(v);
-    write((unsigned char*)&value, sizeof(value));
+    write( (unsigned char*)&value, sizeof(value) );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void EndianWriter::writeUInt16(uint16_t v) throw(IOException)
+void EndianWriter::writeUInt16( uint16_t v ) throw( IOException )
 {
     // Write a short, byteswap if necessary
     uint16_t value = Endian::byteSwap(v) ;
-    write((unsigned char*)&value, sizeof(value));
+    write( (unsigned char*)&value, sizeof(value) );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void EndianWriter::writeUInt32(uint32_t v) throw(IOException)
+void EndianWriter::writeUInt32( uint32_t v ) throw( IOException )
 {
     // Write an int, byteswap if necessary
     uint32_t value = Endian::byteSwap(v);
@@ -79,11 +77,11 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void EndianWriter::writeUInt64(uint64_t v) throw(IOException)
+void EndianWriter::writeUInt64( uint64_t v ) throw( IOException )
 {
     // Write a long long, byteswap if necessary
     uint64_t value = Endian::byteSwap(v);
-    write((unsigned char*)&value, sizeof(value));
+    write( (unsigned char*)&value, sizeof(value) );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -103,7 +101,7 @@
 }*/
 
 ////////////////////////////////////////////////////////////////////////////////
-void EndianWriter::write(const unsigned char* buffer, int count) throw(IOException){
+void EndianWriter::write( const unsigned char* buffer, int count ) throw( IOException ){
 	
 	if( outputStream == NULL ){
 		throw IOException( __FILE__, __LINE__, 

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/io/EndianWriter.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/io/EndianWriter.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/io/EndianWriter.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/io/EndianWriter.h Fri Jul 21 04:36:09 2006
@@ -24,108 +24,109 @@
 namespace activemq{
 namespace io{
 
-	/*
-	 * The BinaryWriter class writes primitive C++ data types to an
-	 * underlying output stream in a Java compatible way. Strings
-	 * are written as raw bytes, no character encoding is performed.
-	 *
-	 * All numeric data types are written in big endian (network byte
-	 * order) and if the platform is little endian they are converted
-	 * automatically.
-	 *
-	 * Should any error occur an IOException will be thrown.
-	 */
-	class EndianWriter : public Writer
-	{
-	private:
-	
-		/**
-		 * Target output stream.
-		 */
-		OutputStream* outputStream;
-		
-	public:
-	
-		/**
-		 * Constructor.
-		 */
-	    EndianWriter();
-	    
-	    /**
-	     * Constructor.
-	     * @param os the target output stream.
-	     */
-	    EndianWriter( OutputStream* os );
-	    
-	    /**
-	     * Destructor.
-	     */
-	    virtual ~EndianWriter();
-	
-		/**
-		 * Sets the target output stream.
-		 */
-		virtual void setOutputStream( OutputStream* os ){
-			outputStream = os;
-		}
-		
-		/**
-		 * Gets the target output stream.
-		 */
-	    virtual OutputStream* getOutputStream(){
-	    	return outputStream;
-	    }
-	    
-	    /**
-	     * Writes a byte array to the target output stream.
-	     * @param buffer a byte array.
-	     * @param count the number of bytes to write.
-	     * @throws IOException thrown if an error occurs.
-	     */
-	    virtual void write(const unsigned char* buffer, int count) throw(IOException);
-	    
-	    /**
-	     * Writes a byte to the target output stream.
-	     * @param v the value to be written
-	     * @throws IOException thrown if an error occurs.
-	     */
-	    virtual void writeByte(unsigned char v) throw(IOException);
-	    
-	    /**
-	     * Writes a double to the target output stream.
-	     * @param v the value to be written
-	     * @throws IOException thrown if an error occurs.
-	     */
-	    virtual void writeDouble(double v) throw(IOException);
-	    
-	    /**
-	     * Writes a float to the target output stream.
-	     * @param v the value to be written
-	     * @throws IOException thrown if an error occurs.
-	     */
-	    virtual void writeFloat(float v) throw(IOException);
-	    
-	    /**
-	     * Writes a short to the target output stream.
-	     * @param v the value to be written
-	     * @throws IOException thrown if an error occurs.
-	     */
-	    virtual void writeUInt16(uint16_t v) throw(IOException);
-	    
-	    /**
-	     * Writes an int to the target output stream.
-	     * @param v the value to be written
-	     * @throws IOException thrown if an error occurs.
-	     */
-	    virtual void writeUInt32(uint32_t v) throw(IOException);
-	    
-	    /**
-	     * Writes a long long to the target output stream.
-	     * @param v the value to be written
-	     * @throws IOException thrown if an error occurs.
-	     */
-	    virtual void writeUInt64(uint64_t v) throw(IOException);
-	};
+    /*
+     * The EndianWriter class writes primitive C++ data types to an
+     * underlying output stream in a Java compatible way. Strings
+     * are written as raw bytes, no character encoding is performed.
+     *
+     * All numeric data types are written in big endian (network byte
+     * order) and if the platform is little endian they are converted
+     * automatically.
+     *
+     * Should any error occur an IOException will be thrown.
+     */
+    class EndianWriter : public Writer
+    {
+    private:
+    
+        /**
+         * Target output stream.
+         */
+        OutputStream* outputStream;
+        
+    public:
+    
+        /**
+         * Default Constructor.
+         */
+        EndianWriter();
+        
+        /**
+         * Constructor.
+         * @param os the target output stream.
+         */
+        EndianWriter( OutputStream* os );
+        
+        /**
+         * Destructor.
+         */
+        virtual ~EndianWriter();
+    
+        /**
+         * Sets the target output stream.
+         */
+        virtual void setOutputStream( OutputStream* os ){
+            outputStream = os;
+        }
+        
+        /**
+         * Gets the target output stream.
+         */
+        virtual OutputStream* getOutputStream(){
+            return outputStream;
+        }
+        
+        /**
+         * Writes a byte array to the target output stream.
+         * @param buffer a byte array.
+         * @param count the number of bytes to write.
+         * @throws IOException thrown if an error occurs.
+         */
+        virtual void write( const unsigned char* buffer, int count ) 
+            throw( IOException );
+        
+        /**
+         * Writes a byte to the target output stream.
+         * @param v the value to be written
+         * @throws IOException thrown if an error occurs.
+         */
+        virtual void writeByte( unsigned char v ) throw( IOException );
+        
+        /**
+         * Writes a double to the target output stream.
+         * @param v the value to be written
+         * @throws IOException thrown if an error occurs.
+         */
+        virtual void writeDouble( double v ) throw( IOException );
+        
+        /**
+         * Writes a float to the target output stream.
+         * @param v the value to be written
+         * @throws IOException thrown if an error occurs.
+         */
+        virtual void writeFloat( float v ) throw( IOException );
+        
+        /**
+         * Writes a short to the target output stream.
+         * @param v the value to be written
+         * @throws IOException thrown if an error occurs.
+         */
+        virtual void writeUInt16( uint16_t v ) throw( IOException );
+        
+        /**
+         * Writes an int to the target output stream.
+         * @param v the value to be written
+         * @throws IOException thrown if an error occurs.
+         */
+        virtual void writeUInt32( uint32_t v ) throw( IOException );
+        
+        /**
+         * Writes a long long to the target output stream.
+         * @param v the value to be written
+         * @throws IOException thrown if an error occurs.
+         */
+        virtual void writeUInt64( uint64_t v ) throw( IOException );
+    };
 
 }}
 

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/io/IOException.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/io/IOException.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/io/IOException.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/io/IOException.h Fri Jul 21 04:36:09 2006
@@ -22,30 +22,31 @@
 namespace activemq{
 namespace io{
 
-	/*
-	 * Signals that an I/O exception of some sort has occurred.
-	 */
-	class IOException : public exceptions::ActiveMQException
-	{
-	public:
-	    IOException(){}
+    /*
+     * Signals that an I/O exception of some sort has occurred.
+     */
+    class IOException : public exceptions::ActiveMQException
+    {
+    public:
+
+        IOException(){}
         IOException( const exceptions::ActiveMQException& ex ){
             *(exceptions::ActiveMQException*)this = ex;
         }
         IOException( const IOException& ex ){
             *(exceptions::ActiveMQException*)this = ex;
         }
-	    IOException(const char* file, const int lineNumber,
-            const char* msg, ...)
-	    {
-	        va_list vargs ;
-            va_start(vargs, msg) ;
-            buildMessage(msg, vargs) ;
+        IOException( const char* file, const int lineNumber,
+                     const char* msg, ... )
+        {
+            va_list vargs;
+            va_start( vargs, msg );
+            buildMessage( msg, vargs );
             
             // Set the first mark for this exception.
             setMark( file, lineNumber );
-	    }
-	    
+        }
+        
         /**
          * Clones this exception.  This is useful for cases where you need
          * to preserve the type of the original exception as well as the message.
@@ -55,9 +56,9 @@
             return new IOException( *this );
         }
         
-	    virtual ~IOException(){}
-	    
-	};
+        virtual ~IOException(){}
+        
+    };
 
 }}
 

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/io/InputStream.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/io/InputStream.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/io/InputStream.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/io/InputStream.h Fri Jul 21 04:36:09 2006
@@ -24,43 +24,44 @@
 
 namespace activemq{
 namespace io{
-	
-	/**
-	 * Base interface for an input stream.
-	 */
-	class InputStream 
-	: 
-		public cms::Closeable,
-		public concurrent::Synchronizable
-	{
-		
-	public:
-	
-		virtual ~InputStream(){}
-		
-		/**
-	     * Indcates the number of bytes avaialable.
-	     * @return the number of bytes available on this input stream.
-	     */
-		virtual int available() const = 0;
-		
-		/**
-		 * Reads a single byte from the buffer.
-		 * @return The next byte.
-		 * @throws IOException thrown if an error occurs.
-		 */
-		virtual unsigned char read() throw (IOException) = 0;
-		
-		/**
-		 * Reads an array of bytes from the buffer.
-		 * @param buffer (out) the target buffer.
-		 * @param bufferSize the size of the output buffer.
-		 * @return The number of bytes read.
-		 * @throws IOException thrown if an error occurs.
-		 */
-		virtual int read( unsigned char* buffer, const int bufferSize ) throw (IOException) = 0;
-	};
-	
+    
+    /**
+     * Base interface for an input stream.
+     */
+    class InputStream 
+    : 
+        public cms::Closeable,
+        public concurrent::Synchronizable
+    {
+        
+    public:
+    
+        virtual ~InputStream(){}
+        
+        /**
+         * Indcates the number of bytes avaialable.
+         * @return the number of bytes available on this input stream.
+         */
+        virtual int available() const = 0;
+        
+        /**
+         * Reads a single byte from the buffer.
+         * @return The next byte.
+         * @throws IOException thrown if an error occurs.
+         */
+        virtual unsigned char read() throw ( IOException ) = 0;
+        
+        /**
+         * Reads an array of bytes from the buffer.
+         * @param buffer (out) the target buffer.
+         * @param bufferSize the size of the output buffer.
+         * @return The number of bytes read.
+         * @throws IOException thrown if an error occurs.
+         */
+        virtual int read( unsigned char* buffer, const int bufferSize ) 
+            throw ( IOException ) = 0;
+    };
+    
 }}
 
 #endif /*ACTIVEMQ_IO_INPUTSTREAM_H_*/

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/io/OutputStream.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/io/OutputStream.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/io/OutputStream.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/io/OutputStream.h Fri Jul 21 04:36:09 2006
@@ -25,39 +25,40 @@
 namespace activemq{
 namespace io{
 
-	/**
-	 * Base interface for an output stream.
-	 */
-	class OutputStream 
-	: 
-		public cms::Closeable,
-		public concurrent::Synchronizable
-	{
-	public:
-	
-		virtual ~OutputStream(){}
-		
-		/**
-		 * Writes a single byte to the output stream.
-		 * @param c the byte.
-		 * @throws IOException thrown if an error occurs.
-		 */
-		virtual void write( const unsigned char c ) throw (IOException) = 0;
-		
-		/**
-		 * Writes an array of bytes to the output stream.
-		 * @param buffer The array of bytes to write.
-		 * @param len The number of bytes from the buffer to be written.
-		 * @throws IOException thrown if an error occurs.
-		 */
-		virtual void write( const unsigned char* buffer, const int len ) throw (IOException) = 0;
-		
-		/**
-		 * Flushes any pending writes in this output stream.
-		 */
-		virtual void flush() throw (IOException) = 0;
-	};
-		
+    /**
+     * Base interface for an output stream.
+     */
+    class OutputStream 
+    : 
+        public cms::Closeable,
+        public concurrent::Synchronizable
+    {
+    public:
+    
+        virtual ~OutputStream(){}
+        
+        /**
+         * Writes a single byte to the output stream.
+         * @param c the byte.
+         * @throws IOException thrown if an error occurs.
+         */
+        virtual void write( const unsigned char c ) throw ( IOException ) = 0;
+        
+        /**
+         * Writes an array of bytes to the output stream.
+         * @param buffer The array of bytes to write.
+         * @param len The number of bytes from the buffer to be written.
+         * @throws IOException thrown if an error occurs.
+         */
+        virtual void write( const unsigned char* buffer, const int len ) 
+            throw ( IOException ) = 0;
+        
+        /**
+         * Flushes any pending writes in this output stream.
+         */
+        virtual void flush() throw ( IOException ) = 0;
+    };
+        
 }}
 
 #endif /*ACTIVEMQ_IO_OUTPUTSTREAM_H*/

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/io/Reader.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/io/Reader.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/io/Reader.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/io/Reader.h Fri Jul 21 04:36:09 2006
@@ -24,42 +24,44 @@
 namespace activemq{
 namespace io{
 
-	/*
-	 * Reader interface that wraps around an input stream and provides
-	 * an interface for extracting the data from the input stream.
-	 */
-	class Reader
-	{
-	public:
-	
-	    virtual ~Reader(){};
-	
-		/**
-		 * Sets the target input stream.
-		 */
-		virtual void setInputStream( InputStream* is ) = 0;
-		
-		/**
-		 * Gets the target input stream.
-		 */
-	    virtual InputStream* getInputStream() = 0;
-	    
-	    /**
-	     * Attempts to read an array of bytes from the stream.
-	     * @param buffer The target byte buffer.
-	     * @param count The number of bytes to read.
-	     * @return The number of bytes read.
-	     * @throws IOException thrown if an error occurs.
-	     */
-	    virtual int read(unsigned char* buffer, int count) throw(IOException) = 0;
-	    
-	    /**
-	     * Attempts to read a byte from the input stream
-	     * @return The byte.
-	     * @throws IOException thrown if an error occurs.
-	     */
-	    virtual unsigned char readByte() throw(IOException) = 0;
-	} ;
+    /*
+     * Reader interface that wraps around an input stream and provides
+     * an interface for extracting the data from the input stream.
+     */
+    class Reader
+    {
+    public:
+    
+        virtual ~Reader(){};
+    
+        /**
+         * Sets the target input stream.
+         */
+        virtual void setInputStream( InputStream* is ) = 0;
+        
+        /**
+         * Gets the target input stream.
+         */
+        virtual InputStream* getInputStream() = 0;
+        
+        /**
+         * Attempts to read an array of bytes from the stream.
+         * @param buffer The target byte buffer.
+         * @param count The number of bytes to read.
+         * @return The number of bytes read.
+         * @throws IOException thrown if an error occurs.
+         */
+        virtual int read( unsigned char* buffer, int count ) 
+            throw( IOException ) = 0;
+        
+        /**
+         * Attempts to read a byte from the input stream
+         * @return The byte.
+         * @throws IOException thrown if an error occurs.
+         */
+        virtual unsigned char readByte() throw( IOException ) = 0;
+        
+    };
 
 }}
 

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/io/StandardErrorOutputStream.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/io/StandardErrorOutputStream.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/io/StandardErrorOutputStream.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/io/StandardErrorOutputStream.h Fri Jul 21 04:36:09 2006
@@ -25,128 +25,127 @@
 namespace activemq{
 namespace io{
 
-   class StandardErrorOutputStream : public OutputStream
-   {
-   private:
+    class StandardErrorOutputStream : public OutputStream
+    {
+    private:
    
-      /**
-       * Synchronization object.
-       */
-      concurrent::Mutex mutex;
+        /**
+         * Synchronization object.
+         */
+        concurrent::Mutex mutex;
 
-   public:
+    public:
 
-      /**
-       * Constructor
-       */
-   	StandardErrorOutputStream(void) {}
+        /**
+         * Default Constructor
+         */
+        StandardErrorOutputStream(void) {}
       
-      /**
-       * Destructor
-       */
-   	virtual ~StandardErrorOutputStream(void) {}
+        virtual ~StandardErrorOutputStream(void) {}
 
-      /**
-       * Waits on a signal from this object, which is generated
-       * by a call to Notify.  Must have this object locked before
-       * calling.
-       * @throws ActiveMQException
-       */
-      virtual void lock() throw(exceptions::ActiveMQException){
-          mutex.lock();
-      }
+        /**
+         * Waits on a signal from this object, which is generated
+         * by a call to Notify.  Must have this object locked before
+         * calling.
+         * @throws ActiveMQException
+         */
+        virtual void lock() throw( exceptions::ActiveMQException ){
+            mutex.lock();
+        }
     
-      /**
-       * Unlocks the object.
-       * @throws ActiveMQException
-       */
-      virtual void unlock() throw(exceptions::ActiveMQException){ 
-          mutex.unlock();
-      }
+        /**
+         * Unlocks the object.
+         * @throws ActiveMQException
+         */
+        virtual void unlock() throw( exceptions::ActiveMQException ){ 
+            mutex.unlock();
+        }
         
-      /**
-       * Waits on a signal from this object, which is generated
-       * by a call to Notify.  Must have this object locked before
-       * calling.
-       * @throws ActiveMQException
-       */
-      virtual void wait() throw(exceptions::ActiveMQException){
-          mutex.wait();
-      }
+        /**
+         * Waits on a signal from this object, which is generated
+         * by a call to Notify.  Must have this object locked before
+         * calling.
+         * @throws ActiveMQException
+         */
+        virtual void wait() throw( exceptions::ActiveMQException ){
+            mutex.wait();
+        }
     
-      /**
-       * Waits on a signal from this object, which is generated
-       * by a call to Notify.  Must have this object locked before
-       * calling.  This wait will timeout after the specified time
-       * interval.
-       * @param time in millisecsonds to wait, or WAIT_INIFINITE
-       * @throws ActiveMQException
-       */
-      virtual void wait(unsigned long millisecs) throw(exceptions::ActiveMQException){
-          mutex.wait(millisecs);
-      }
+        /**
+         * Waits on a signal from this object, which is generated
+         * by a call to Notify.  Must have this object locked before
+         * calling.  This wait will timeout after the specified time
+         * interval.
+         * @param time in millisecsonds to wait, or WAIT_INIFINITE
+         * @throws ActiveMQException
+         */
+        virtual void wait( unsigned long millisecs ) throw( exceptions::ActiveMQException ){
+            mutex.wait( millisecs );
+        }
 
-      /**
-       * Signals a waiter on this object that it can now wake
-       * up and continue.  Must have this object locked before
-       * calling.
-       * @throws ActiveMQException
-       */
-      virtual void notify() throw(exceptions::ActiveMQException){
-          mutex.notify();
-      }
+        /**
+         * Signals a waiter on this object that it can now wake
+         * up and continue.  Must have this object locked before
+         * calling.
+         * @throws ActiveMQException
+         */
+        virtual void notify() throw( exceptions::ActiveMQException ){
+            mutex.notify();
+        }
         
-      /**
-       * Signals the waiters on this object that it can now wake
-       * up and continue.  Must have this object locked before
-       * calling.
-       * @throws ActiveMQException
-       */
-      virtual void notifyAll() throw(exceptions::ActiveMQException){
-          mutex.notifyAll();
-      }
+        /**
+         * Signals the waiters on this object that it can now wake
+         * up and continue.  Must have this object locked before
+         * calling.
+         * @throws ActiveMQException
+         */
+        virtual void notifyAll() throw( exceptions::ActiveMQException ){
+            mutex.notifyAll();
+        }
        
-      /**
-       * Writes a single byte to the output stream.
-       * @param c the byte.
-       * @throws IOException thrown if an error occurs.
-       */
-      virtual void write( const unsigned char c ) 
-         throw (IOException)
-      {
-         std::cerr << c;
-      }
+        /**
+         * Writes a single byte to the output stream.
+         * @param c the byte.
+         * @throws IOException thrown if an error occurs.
+         */
+        virtual void write( const unsigned char c ) 
+            throw ( IOException )
+        {
+           std::cerr << c;
+        }
       
-      /**
-       * Writes an array of bytes to the output stream.
-       * @param buffer The array of bytes to write.
-       * @param len The number of bytes from the buffer to be written.
-       * @throws IOException thrown if an error occurs.
-       */
-      virtual void write( const unsigned char* buffer, const int len ) 
-         throw (IOException)
-      {
-         for(int i = 0; i < len; ++i)
-         {
-            std::cerr << buffer[i];
-         }
-      }
+        /**
+         * Writes an array of bytes to the output stream.
+         * @param buffer The array of bytes to write.
+         * @param len The number of bytes from the buffer to be written.
+         * @throws IOException thrown if an error occurs.
+         */
+        virtual void write( const unsigned char* buffer, const int len ) 
+            throw ( IOException )
+        {
+            for(int i = 0; i < len; ++i)
+            {
+                std::cerr << buffer[i];
+            }
+        }
       
-      /**
-       * Invokes flush on the target output stream.
-       */
-      virtual void flush() throw (IOException){
-         std::cerr.flush();
-      }
+        /**
+         * Invokes flush on the target output stream.
+         * throws IOException if an error occurs
+         */
+        virtual void flush() throw ( IOException ){
+            std::cerr.flush();
+        }
       
-      /**
-       * Invokes close on the target output stream.
-       */
-      void close() throw(cms::CMSException){
-         std::cerr.flush();
-      }
+        /**
+         * Invokes close on the target output stream.
+         * throws CMSException if an error occurs
+         */
+        void close() throw( cms::CMSException ){
+            std::cerr.flush();
+        }
 
-   };
+    };
 
 }
 

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/io/Writer.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/io/Writer.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/io/Writer.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/io/Writer.h Fri Jul 21 04:36:09 2006
@@ -24,41 +24,43 @@
 namespace activemq{
 namespace io{
 
-   /*
-    * Writer interface for an object that wraps around an output
-    * stream 
-    */
-   class Writer
-   {
-   public:
+    /*
+     * Writer interface for an object that wraps around an output
+     * stream 
+     */
+    class Writer
+    {
+    public:
    
-      virtual ~Writer(){};
+        virtual ~Writer(){};
        
-      /**
-       * Sets the target output stream.
-       */
-      virtual void setOutputStream( OutputStream* os ) = 0;
+        /**
+         * Sets the target output stream.
+         * @param Outputstream to use
+         */
+        virtual void setOutputStream( OutputStream* os ) = 0;
        
-      /**
-       * Gets the target output stream.
-       */
-      virtual OutputStream* getOutputStream() = 0;
+        /**
+         * Gets the target output stream.
+         * @returns the output stream currently being used
+         */
+        virtual OutputStream* getOutputStream() = 0;
              
-      /**
-       * Writes a byte array to the output stream.
-       * @param buffer a byte array
-       * @param count the number of bytes in the array to write.
-       * @throws IOException thrown if an error occurs.
-       */
-      virtual void write(const unsigned char* buffer, int count) throw(IOException) = 0;
+        /**
+         * Writes a byte array to the output stream.
+         * @param buffer a byte array
+         * @param count the number of bytes in the array to write.
+         * @throws IOException thrown if an error occurs.
+         */
+        virtual void write( const unsigned char* buffer, int count ) throw( IOException ) = 0;
        
-       /**
-        * Writes a byte to the output stream.
-        * @param v The value to be written.
-        * @throws IOException thrown if an error occurs.
-        */
-       virtual void writeByte(unsigned char v) throw(IOException) = 0;
-   };
+         /**
+          * Writes a byte to the output stream.
+          * @param v The value to be written.
+          * @throws IOException thrown if an error occurs.
+          */
+         virtual void writeByte( unsigned char v ) throw( IOException ) = 0;
+    };
 
 }}
 

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/BufferedSocket.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/BufferedSocket.cpp?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/BufferedSocket.cpp (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/BufferedSocket.cpp Fri Jul 21 04:36:09 2006
@@ -25,97 +25,97 @@
 using namespace activemq::exceptions;
 
 ////////////////////////////////////////////////////////////////////////////////
-BufferedSocket::BufferedSocket(Socket* socket,
-                               unsigned int inputBufferSize,
-                               unsigned int outputBufferSize,
-                               bool own)
+BufferedSocket::BufferedSocket( Socket* socket,
+                                unsigned int inputBufferSize,
+                                unsigned int outputBufferSize,
+                                bool own )
 {
-   if(socket == NULL)
-   {
-      throw IllegalArgumentException(
-         __FILE__, __LINE__,
-         "BufferedSocket::BufferedSocket - Constructed with NULL Socket");
-   }
+    if(socket == NULL)
+    {
+        throw IllegalArgumentException(
+            __FILE__, __LINE__,
+            "BufferedSocket::BufferedSocket - Constructed with NULL Socket");
+    }
    
-   this->socket = socket;
-   this->inputBufferSize = inputBufferSize;
-   this->outputBufferSize = outputBufferSize;
-   this->own = own;
+    this->socket = socket;
+    this->inputBufferSize = inputBufferSize;
+    this->outputBufferSize = outputBufferSize;
+    this->own = own;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 BufferedSocket::~BufferedSocket(void)
 {
-   try
-   {
-      if(outputStream)
-      {
-         // Ensure all data is written
-         outputStream->flush();
-      }
+    try
+    {
+        if( outputStream )
+        {
+            // Ensure all data is written
+            outputStream->flush();
+        }
 
-      // Close the socket      
-      socket->close();
+        // Close the socket      
+        socket->close();
          
-      // if we own it, delete it.
-      if(own)
-      {
-         delete socket;
-      }
+        // if we own it, delete it.
+        if( own )
+        {
+            delete socket;
+        }
       
-      // Clean up our streams.
-      delete inputStream;
-      delete outputStream;
-   }
-   AMQ_CATCH_NOTHROW( ActiveMQException )
-   AMQ_CATCHALL_NOTHROW( )
+        // Clean up our streams.
+        delete inputStream;
+        delete outputStream;
+    }
+    AMQ_CATCH_NOTHROW( ActiveMQException )
+    AMQ_CATCHALL_NOTHROW( )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 void BufferedSocket::connect( const char* host, const int port ) 
-   throw( SocketException )
+    throw( SocketException )
 {
-   try
-   {      
-      if( socket->isConnected() )
-      {
-         throw SocketException( __FILE__, __LINE__, 
-               "BufferedSocket::connect() - socket already connected" );
-      }
-
-      // Connect the socket.
-      socket->connect( host, port );
-
-      // Now create the buffered streams that wrap around the socket.
-      inputStream = new BufferedInputStream( 
-         socket->getInputStream(), inputBufferSize );
-      outputStream = new BufferedOutputStream( 
-         socket->getOutputStream(), outputBufferSize );
-   }
-   AMQ_CATCH_RETHROW( SocketException )
-   AMQ_CATCH_EXCEPTION_CONVERT( ActiveMQException, SocketException )
-   AMQ_CATCHALL_THROW( SocketException )   
+    try
+    {      
+        if( socket->isConnected() )
+        {
+            throw SocketException( __FILE__, __LINE__, 
+                 "BufferedSocket::connect() - socket already connected" );
+        }
+
+        // Connect the socket.
+        socket->connect( host, port );
+
+        // Now create the buffered streams that wrap around the socket.
+        inputStream = new BufferedInputStream( 
+            socket->getInputStream(), inputBufferSize );
+        outputStream = new BufferedOutputStream( 
+            socket->getOutputStream(), outputBufferSize );
+    }
+    AMQ_CATCH_RETHROW( SocketException )
+    AMQ_CATCH_EXCEPTION_CONVERT( ActiveMQException, SocketException )
+    AMQ_CATCHALL_THROW( SocketException )   
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 void BufferedSocket::close(void) throw( cms::CMSException )
 {
-   try
-   {
-      // Ensure all data writen
-      outputStream->flush();
+    try
+    {
+        // Ensure all data writen
+        outputStream->flush();
       
-      // Close the Socket
-      socket->close();
+        // Close the Socket
+        socket->close();
       
-      // Remove old stream, recreate if reconnected
-      delete inputStream;
-      delete outputStream;
+        // Remove old stream, recreate if reconnected
+        delete inputStream;
+        delete outputStream;
       
-      inputStream = NULL;
-      outputStream = NULL;
-   }
-   AMQ_CATCH_RETHROW( SocketException )
-   AMQ_CATCH_EXCEPTION_CONVERT( ActiveMQException, SocketException )
-   AMQ_CATCHALL_THROW( SocketException )   
+        inputStream = NULL;
+        outputStream = NULL;
+    }
+    AMQ_CATCH_RETHROW( SocketException )
+    AMQ_CATCH_EXCEPTION_CONVERT( ActiveMQException, SocketException )
+    AMQ_CATCHALL_THROW( SocketException )   
 }

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/BufferedSocket.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/BufferedSocket.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/BufferedSocket.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/BufferedSocket.h Fri Jul 21 04:36:09 2006
@@ -25,195 +25,190 @@
 namespace activemq{
 namespace network{
 
-   /**
-    * Buffered Socket class that wraps a <code>Socket</code> derived
-    * object and provides Buffered input and Output Streams to improce
-    * the efficiency of the reads and writes.
-    */
-   class BufferedSocket : public Socket
-   {
-   private:
+    /**
+     * Buffered Socket class that wraps a <code>Socket</code> derived
+     * object and provides Buffered input and Output Streams to improce
+     * the efficiency of the reads and writes.
+     */
+    class BufferedSocket : public Socket
+    {
+    private:
    
-      // Socket that this class wraps to provide buffering
-      Socket* socket;
+        // Socket that this class wraps to provide buffering
+        Socket* socket;
       
-      // Indicates if the lifetime of the Socket is controlled by this 
-      // class.  If true Socket is deleted at destruction.
-      bool own;
-      
-      // Buffered Input stream to wrap the Socket input stream
-      io::BufferedInputStream* inputStream;
-      
-      // Buffered Output stream to wrap the Socket input stream
-      io::BufferedOutputStream* outputStream;
-      
-      // Sizes for the Buffered Streams
-      unsigned int inputBufferSize;
-      unsigned int outputBufferSize;
-
-   public:
-
-      /**
-       * Constructor
-       */
-   	BufferedSocket(Socket* socket, 
-                     unsigned int inputBufferSize = 1000,
-                     unsigned int outputBufferSize = 1000,
-                     bool own = true);
-
-      /**
-       * Destructor
-       */
-   	virtual ~BufferedSocket(void);
-
-       /**
-       * 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 IOException Thrown if a failure occurred in the connect.
-       */
-      virtual void connect( const char* host, const int port ) 
-         throw(SocketException);
-      
-      /**
-       * Closes this object and deallocates the appropriate resources.
-       * @throws CMSException
-       */
-      virtual void close() throw( cms::CMSException );
-
-      /**
-       * Indicates whether or not this socket is connected to a destination.
-       */
-      virtual bool isConnected() const{
-         return socket->isConnected();
-      }
-
-      /**
-       * Gets the InputStream for this socket.
-       * @return The InputStream for this socket. NULL if not connected.
-       */
-      virtual io::InputStream* getInputStream(){
-         return inputStream;
-      }
-      
-      /**
-       * Gets the OutputStream for this socket.
-       * @return the OutputStream for this socket.  NULL if not connected.
-       */
-      virtual io::OutputStream* getOutputStream(){
-         return outputStream;
-      }
-
-      /**
-       * Gets the linger time.
-       * @return The linger time in seconds.
-       * @throws SocketException if the operation fails.
-       */
-      virtual int getSoLinger() const throw(SocketException){
-         return socket->getSoLinger();
-      }
-      
-      /**
-       * Sets the linger time.
-       * @param linger The linger time in seconds.  If 0, linger is off.
-       * @throws SocketException if the operation fails.
-       */
-      virtual void setSoLinger( const int linger ) throw(SocketException){
-         socket->setSoLinger(linger);
-      }
-      
-      /**
-       * Gets the keep alive flag.
-       * @return True if keep alive is enabled.
-       * @throws SocketException if the operation fails.
-       */
-      virtual bool getKeepAlive() const throw(SocketException){
-         return socket->getKeepAlive();
-      }
-      
-      /**
-       * Enables/disables the keep alive flag.
-       * @param keepAlive If true, enables the flag.
-       * @throws SocketException if the operation fails.
-       */
-      virtual void setKeepAlive( const bool keepAlive ) throw(SocketException){
-         socket->setKeepAlive(keepAlive);
-      }
-      
-      /**
-       * Gets the receive buffer size.
-       * @return the receive buffer size in bytes.
-       * @throws SocketException if the operation fails.
-       */
-      virtual int getReceiveBufferSize() const throw(SocketException){
-         return socket->getReceiveBufferSize();
-      }
-      
-      /**
-       * Sets the recieve buffer size.
-       * @param size Number of bytes to set the receive buffer to.
-       * @throws SocketException if the operation fails.
-       */
-      virtual void setReceiveBufferSize( const int size ) throw(SocketException){
-         socket->setReceiveBufferSize(size);
-      }
-      
-      /**
-       * Gets the reuse address flag.
-       * @return True if the address can be reused.
-       * @throws SocketException if the operation fails.
-       */
-      virtual bool getReuseAddress() const throw(SocketException){
-         return socket->getReuseAddress();
-      }
-      
-      /**
-       * Sets the reuse address flag.
-       * @param reuse If true, sets the flag.
-       * @throws SocketException if the operation fails.
-       */
-      virtual void setReuseAddress( const bool reuse ) throw(SocketException){
-         socket->setReuseAddress(reuse);
-      }
-      
-      /**
-       * Gets the send buffer size.
-       * @return the size in bytes of the send buffer.
-       * @throws SocketException if the operation fails.
-       */
-      virtual int getSendBufferSize() const throw(SocketException){
-         return socket->getSendBufferSize();
-      }
-      
-      /**
-       * Sets the send buffer size.
-       * @param size The number of bytes to set the send buffer to.
-       * @throws SocketException if the operation fails.
-       */
-      virtual void setSendBufferSize( const int size ) throw(SocketException){
-         socket->setSendBufferSize(size);
-      }
-      
-      /**
-       * Gets the timeout for socket operations.
-       * @return The timeout in milliseconds for socket operations.
-       * @throws SocketException Thrown if unable to retrieve the information.
-       */
-      virtual int getSoTimeout() const throw(SocketException){
-         return socket->getSoTimeout();
-      }
-      
-      /**
-       * 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.
-       */
-      virtual void setSoTimeout( const int timeout ) throw(SocketException){
-         socket->setSoTimeout(timeout);
-      }
+        // Indicates if the lifetime of the Socket is controlled by this 
+        // class.  If true Socket is deleted at destruction.
+        bool own;
+      
+        // Buffered Input stream to wrap the Socket input stream
+        io::BufferedInputStream* inputStream;
+      
+        // Buffered Output stream to wrap the Socket input stream
+        io::BufferedOutputStream* outputStream;
+      
+        // Sizes for the Buffered Streams
+        unsigned int inputBufferSize;
+        unsigned int outputBufferSize;
+
+    public:
+
+        BufferedSocket( Socket* socket, 
+                        unsigned int inputBufferSize = 1000,
+                        unsigned int outputBufferSize = 1000,
+                        bool own = true );
+
+        virtual ~BufferedSocket(void);
+
+        /**
+         * 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 IOException Thrown if a failure occurred in the connect.
+         */
+        virtual void connect( const char* host, const int port ) 
+            throw( SocketException );
+      
+        /**
+         * Closes this object and deallocates the appropriate resources.
+         * @throws CMSException
+         */
+        virtual void close() throw( cms::CMSException );
+
+        /**
+         * Indicates whether or not this socket is connected to a destination.
+         * @return true if connected
+         */
+        virtual bool isConnected() const{
+            return socket->isConnected();
+        }
+
+        /**
+         * Gets the InputStream for this socket.
+         * @return The InputStream for this socket. NULL if not connected.
+         */
+        virtual io::InputStream* getInputStream(){
+            return inputStream;
+        }
+      
+        /**
+         * Gets the OutputStream for this socket.
+         * @return the OutputStream for this socket.  NULL if not connected.
+         */
+        virtual io::OutputStream* getOutputStream(){
+            return outputStream;
+        }
+
+        /**
+         * Gets the linger time.
+         * @return The linger time in seconds.
+         * @throws SocketException if the operation fails.
+         */
+        virtual int getSoLinger() const throw( SocketException ){
+            return socket->getSoLinger();
+        }
+      
+        /**
+         * Sets the linger time.
+         * @param linger The linger time in seconds.  If 0, linger is off.
+         * @throws SocketException if the operation fails.
+         */
+        virtual void setSoLinger( const int linger ) throw( SocketException ){
+            socket->setSoLinger( linger );
+        }
+      
+        /**
+         * Gets the keep alive flag.
+         * @return True if keep alive is enabled.
+         * @throws SocketException if the operation fails.
+         */
+        virtual bool getKeepAlive() const throw( SocketException ){
+            return socket->getKeepAlive();
+        }
+      
+        /**
+         * Enables/disables the keep alive flag.
+         * @param keepAlive If true, enables the flag.
+         * @throws SocketException if the operation fails.
+         */
+        virtual void setKeepAlive( const bool keepAlive ) throw( SocketException ){
+            socket->setKeepAlive( keepAlive );
+        }
+      
+        /**
+         * Gets the receive buffer size.
+         * @return the receive buffer size in bytes.
+         * @throws SocketException if the operation fails.
+         */
+        virtual int getReceiveBufferSize() const throw( SocketException ){
+            return socket->getReceiveBufferSize();
+        }
+      
+        /**
+         * Sets the recieve buffer size.
+         * @param size Number of bytes to set the receive buffer to.
+         * @throws SocketException if the operation fails.
+         */
+        virtual void setReceiveBufferSize( const int size ) throw( SocketException ){
+            socket->setReceiveBufferSize( size );
+        }
+      
+        /**
+         * Gets the reuse address flag.
+         * @return True if the address can be reused.
+         * @throws SocketException if the operation fails.
+         */
+        virtual bool getReuseAddress() const throw( SocketException ){
+            return socket->getReuseAddress();
+        }
+      
+        /**
+         * Sets the reuse address flag.
+         * @param reuse If true, sets the flag.
+         * @throws SocketException if the operation fails.
+         */
+        virtual void setReuseAddress( const bool reuse ) throw( SocketException ){
+            socket->setReuseAddress( reuse );
+        }
+      
+        /**
+         * Gets the send buffer size.
+         * @return the size in bytes of the send buffer.
+         * @throws SocketException if the operation fails.
+         */
+        virtual int getSendBufferSize() const throw( SocketException ){
+            return socket->getSendBufferSize();
+        }
+      
+        /**
+         * Sets the send buffer size.
+         * @param size The number of bytes to set the send buffer to.
+         * @throws SocketException if the operation fails.
+         */
+        virtual void setSendBufferSize( const int size ) throw( SocketException ){
+            socket->setSendBufferSize( size );
+        }
+      
+        /**
+         * Gets the timeout for socket operations.
+         * @return The timeout in milliseconds for socket operations.
+         * @throws SocketException Thrown if unable to retrieve the information.
+         */
+        virtual int getSoTimeout() const throw( SocketException ){
+            return socket->getSoTimeout();
+        }
+      
+        /**
+         * 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.
+         */
+        virtual void setSoTimeout( const int timeout ) throw( SocketException ){
+            socket->setSoTimeout( timeout );
+        }
 
-   };
+    };
 
 }}
 

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/ServerSocket.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/ServerSocket.cpp?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/ServerSocket.cpp (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/ServerSocket.cpp Fri Jul 21 04:36:09 2006
@@ -16,23 +16,23 @@
  */
 
 #if (defined(unix) || defined(__APPLE__)) && !defined(__CYGWIN__)
-   #include <unistd.h>
-   #include <netdb.h>
-   #include <fcntl.h>
-   #include <sys/file.h>
-   #include <sys/socket.h>
-   #include <netinet/in.h>
-   #include <arpa/inet.h>
-   extern int errno;
+    #include <unistd.h>
+    #include <netdb.h>
+    #include <fcntl.h>
+    #include <sys/file.h>
+    #include <sys/socket.h>
+    #include <netinet/in.h>
+    #include <arpa/inet.h>
+    extern int errno;
 #else
-   #include <Winsock2.h>
-   #include <Ws2tcpip.h> 
-   #include <sys/stat.h>
-   #define stat _stat
-   #ifdef errno
-   #undef errno
-   #endif
-   int errno;
+    #include <Winsock2.h>
+    #include <Ws2tcpip.h> 
+    #include <sys/stat.h>
+    #define stat _stat
+    #ifdef errno
+    #undef errno
+    #endif
+    int errno;
 #endif
 
 #include <stdio.h>
@@ -48,28 +48,28 @@
 
 using namespace activemq::network;
 
-#if !(defined( unix ) || defined(__APPLE__)) || defined( __CYGWIN__ )
+#if !defined( unix ) || defined( __CYGWIN__ )
 
-   // Static socket initializer needed for winsock
+    // Static socket initializer needed for winsock
 
-   ServerSocket::StaticServerSocketInitializer::StaticServerSocketInitializer () {
-       socketInitError = NULL;
-       const WORD version_needed = MAKEWORD(2,2); // lo-order byte: major version
-       WSAData temp;
-       if (WSAStartup(version_needed, &temp)){
-         clear();
-           socketInitError = new SocketException ( __FILE__, __LINE__,
-                "winsock.dll was not found");
-       }
-   }
-   ServerSocket::StaticServerSocketInitializer::~StaticServerSocketInitializer () {
-      clear();
-      WSACleanup();
-   }
+    ServerSocket::StaticServerSocketInitializer::StaticServerSocketInitializer () {
+        socketInitError = NULL;
+        const WORD version_needed = MAKEWORD(2,2); // lo-order byte: major version
+        WSAData temp;
+        if( WSAStartup(version_needed, &temp )){
+           clear();
+               socketInitError = new SocketException ( __FILE__, __LINE__,
+                   "winsock.dll was not found");
+        }
+    }
+    ServerSocket::StaticServerSocketInitializer::~StaticServerSocketInitializer () {
+        clear();
+        WSACleanup();
+    }
    
-   // Create static instance of the socket initializer.
-   ServerSocket::StaticServerSocketInitializer 
-      ServerSocket::staticSocketInitializer;
+    // Create static instance of the socket initializer.
+    ServerSocket::StaticServerSocketInitializer 
+        ServerSocket::staticSocketInitializer;
    
 #endif
 
@@ -77,128 +77,127 @@
 ////////////////////////////////////////////////////////////////////////////////
 ServerSocket::ServerSocket()
 {
-   socketHandle = Socket::INVALID_SOCKET_HANDLE;
+    socketHandle = Socket::INVALID_SOCKET_HANDLE;
    
-#if !(defined( unix ) || defined(__APPLE__)) || defined( __CYGWIN__ )
-   if (ServerSocket::staticSocketInitializer.getSocketInitError() != NULL) {
-      throw *ServerSocket::staticSocketInitializer.getSocketInitError();
-   }
+#if !defined( unix ) || defined( __CYGWIN__ )
+    if( ServerSocket::staticSocketInitializer.getSocketInitError() != NULL ) {
+        throw *ServerSocket::staticSocketInitializer.getSocketInitError();
+    }
 #endif
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 ServerSocket::~ServerSocket()
 {
-   // No shutdown, just close - dont want blocking destructor.
-   close();
+    // No shutdown, just close - dont want blocking destructor.
+    close();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ServerSocket::bind (const char* host, int port) throw (SocketException)
+void ServerSocket::bind( const char* host, int port ) throw ( SocketException )
 {
-   bind (host, port, SOMAXCONN);
+    bind (host, port, SOMAXCONN);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ServerSocket::bind (const char* host, int port, int backlog) throw (SocketException)
+void ServerSocket::bind( const char* host, int port, int backlog ) throw ( SocketException )
 {
-   if (isBound()) {
-      throw SocketException ( __FILE__, __LINE__, 
-         "ServerSocket::bind - Socket already bound" );
-   }
+    if(isBound()) {
+        throw SocketException ( __FILE__, __LINE__, 
+            "ServerSocket::bind - Socket already bound" );
+    }
     
     // Create the socket.
-   socketHandle = ::socket(AF_INET, SOCK_STREAM, 0);
-   if (socketHandle < 0) {
-      socketHandle = Socket::INVALID_SOCKET_HANDLE;
-        throw SocketException( __FILE__, __LINE__, ::strerror( errno ));
-   }
+    socketHandle = ::socket(AF_INET, SOCK_STREAM, 0 );
+    if( socketHandle < 0) {
+        socketHandle = Socket::INVALID_SOCKET_HANDLE;
+            throw SocketException( __FILE__, __LINE__, ::strerror( errno ));
+    }
    
-   // Verify the port value.
-   if (port <= 0 || port > 65535) {
-      throw SocketException( __FILE__, __LINE__, 
-         "ServerSocket::bind - Port out of range: %d", port );
-   }
-    
-    
-   sockaddr_in bind_addr;
-   bind_addr.sin_family = AF_INET;
-   bind_addr.sin_port = htons((short)port);
-   bind_addr.sin_addr.s_addr = 0; // To be set later down...
-   memset(&bind_addr.sin_zero, 0, sizeof(bind_addr.sin_zero));
-
-   // Resolve name
-   ::addrinfo hints;
-   memset(&hints, 0, sizeof(addrinfo));
-   hints.ai_family = PF_INET;
-   struct addrinfo *res_ptr = NULL;
-   int status = ::getaddrinfo(host, NULL, &hints, &res_ptr);
-   if( status != 0 || res_ptr == NULL) {
-       throw SocketException( __FILE__, __LINE__, ::strerror( errno ) );
-   }
-   assert(res_ptr->ai_addr->sa_family == AF_INET);
-   // Porting: On both 32bit and 64 bit systems that we compile to soo far, sin_addr is a 32 bit value, not an unsigned long.
-   assert(sizeof(((sockaddr_in*)res_ptr->ai_addr)->sin_addr.s_addr) == 4);
-   bind_addr.sin_addr.s_addr = ((sockaddr_in*)res_ptr->ai_addr)->sin_addr.s_addr;
-   freeaddrinfo(res_ptr);
-
-   // Set the socket to reuse the address.
-   int value = 1;
-   ::setsockopt(socketHandle, SOL_SOCKET, SO_REUSEADDR, (char*)&value, sizeof(int) );
+    // Verify the port value.
+    if( port <= 0 || port > 65535 ) {
+        throw SocketException( __FILE__, __LINE__, 
+            "ServerSocket::bind - Port out of range: %d", port );
+    }
       
-   status = ::bind(socketHandle,
-             (sockaddr *)&bind_addr, sizeof(bind_addr));
+    sockaddr_in bind_addr;
+    bind_addr.sin_family = AF_INET;
+    bind_addr.sin_port = htons((short)port);
+    bind_addr.sin_addr.s_addr = 0; // To be set later down...
+    memset(&bind_addr.sin_zero, 0, sizeof(bind_addr.sin_zero));
+
+    // Resolve name
+    ::addrinfo hints;
+    memset(&hints, 0, sizeof(addrinfo));
+    hints.ai_family = PF_INET;
+    struct addrinfo *res_ptr = NULL;
+    int status = ::getaddrinfo(host, NULL, &hints, &res_ptr);
+    if( status != 0 || res_ptr == NULL) {
+        throw SocketException( __FILE__, __LINE__, ::strerror( errno ) );
+    }
+    assert(res_ptr->ai_addr->sa_family == AF_INET);
+    // Porting: On both 32bit and 64 bit systems that we compile to soo far, sin_addr is a 32 bit value, not an unsigned long.
+    assert(sizeof(((sockaddr_in*)res_ptr->ai_addr)->sin_addr.s_addr) == 4);
+    bind_addr.sin_addr.s_addr = ((sockaddr_in*)res_ptr->ai_addr)->sin_addr.s_addr;
+    freeaddrinfo(res_ptr);
+
+    // Set the socket to reuse the address.
+    int value = 1;
+    ::setsockopt(socketHandle, SOL_SOCKET, SO_REUSEADDR, (char*)&value, sizeof(int) );
+      
+    status = ::bind(socketHandle,
+             (sockaddr *)&bind_addr, sizeof( bind_addr ));
 
-   if( status < 0 ){
+    if( status < 0 ){
         close();
-      throw SocketException ( __FILE__, __LINE__, 
+        throw SocketException ( __FILE__, __LINE__, 
             "ServerSocket::bind - %s", ::strerror( errno ) );
-   }
-   status = ::listen(socketHandle, backlog);
-   if (status < 0) {
-       close();
-       throw SocketException( __FILE__, __LINE__, ::strerror( errno ) );
-   }
+    }
+    status = ::listen( socketHandle, backlog );
+    if( status < 0 ) {
+        close();
+        throw SocketException( __FILE__, __LINE__, ::strerror( errno ) );
+    }
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 void ServerSocket::close() throw (cms::CMSException){
    
-   if (isBound()) {
+    if( isBound() ) {
         
-      #if (defined(unix) || defined(__APPLE__)) && !defined(__CYGWIN__)
-         ::close(socketHandle);
-      #else
-         ::closesocket(socketHandle);
-      #endif
+        #if defined(unix) && !defined( __CYGWIN__ )
+            ::close( socketHandle );
+        #else
+            ::closesocket( socketHandle );
+        #endif
 
-      socketHandle = Socket::INVALID_SOCKET_HANDLE;
-   }
+        socketHandle = Socket::INVALID_SOCKET_HANDLE;
+    }
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 bool ServerSocket::isBound() const {
-   return this->socketHandle != Socket::INVALID_SOCKET_HANDLE;
+    return this->socketHandle != Socket::INVALID_SOCKET_HANDLE;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 Socket* ServerSocket::accept () throw (SocketException)
 {
-   struct sockaddr_in temp;
-
-#if (defined( unix ) || defined(__APPLE__)) && !defined( __CYGWIN__ )
-   socklen_t temp_len = sizeof (sockaddr_in);
-#else
-   int temp_len = sizeof (sockaddr_in);
-#endif
+    struct sockaddr_in temp;
 
-   SocketHandle ss_socket_handle = 
-      ::accept(socketHandle, (struct sockaddr*)&temp, &temp_len);
-   if (ss_socket_handle < 0) {
-      throw SocketException( __FILE__, __LINE__, 
-         "ServerSocket::accept- %s", ::strerror( errno ) );
-   }
+    #if defined( unix ) && !defined( __CYGWIN__ )
+        socklen_t temp_len = sizeof( sockaddr_in );
+    #else
+        int temp_len = sizeof( sockaddr_in );
+    #endif
+
+    SocketHandle ss_socket_handle = 
+        ::accept( socketHandle, (struct sockaddr*)&temp, &temp_len );
+    if( ss_socket_handle < 0 ) {
+        throw SocketException( __FILE__, __LINE__, 
+            "ServerSocket::accept- %s", ::strerror( errno ) );
+    }
     
-   return new TcpSocket(ss_socket_handle);
+    return new TcpSocket( ss_socket_handle );
 }
 

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/ServerSocket.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/ServerSocket.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/ServerSocket.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/ServerSocket.h Fri Jul 21 04:36:09 2006
@@ -23,65 +23,65 @@
 namespace activemq{
 namespace network{
 
-	/**
-	 * A server socket class (for testing purposes).
-	 */
-	class ServerSocket
-	{
-	public:
-	
-	    typedef Socket::SocketHandle SocketHandle;
-	    
-	private:
-	
-	    SocketHandle socketHandle;
-	    
-	public:
-	
-	    /** 
-	     * Constructor.
-	     * Creates a non-bound server socket.
-	     */
-	    ServerSocket();
-	
-	    /**
-	     * Destructor.
-	     * Releases socket handle if close() hasn't been called.
-	     */
-	    virtual ~ServerSocket();
-	    
-	public:
-	
-	    /**
-	     * Bind and listen to given IP/dns and port.
-	     * @param host IP address or host name.
-	     * @param port TCP port between 1..655535
-	     */
-	    virtual void bind (const char* host, int port) throw (SocketException);
-	
-	    /**
-	     * Bind and listen to given IP/dns and port.
-	     * @param host IP address or host name.
-	     * @param port TCP port between 1..655535
-	     * @param backlog Size of listen backlog.
-	     */
-	    virtual void bind (const char* host, int port, int backlog) throw (SocketException);
-	
-	    /**
-	     * Blocks until a client connects to the bound socket.
-	     * @return new socket. Never returns NULL.
-	     */
-	    virtual Socket* accept () throw (SocketException);
-	
-	    /**
-	     * Closes the server socket.
-	     */
-	    virtual void close() throw(cms::CMSException);
-	
-	    /**
-	     * @return true of the server socket is bound.
-	     */ 
-	    virtual bool isBound() const;
+    /**
+     * A server socket class (for testing purposes).
+     */
+    class ServerSocket
+    {
+    public:
+    
+        typedef Socket::SocketHandle SocketHandle;
+        
+    private:
+    
+        SocketHandle socketHandle;
+        
+    public:
+    
+        /** 
+         * Constructor.
+         * Creates a non-bound server socket.
+         */
+        ServerSocket();
+    
+        /**
+         * Destructor.
+         * Releases socket handle if close() hasn't been called.
+         */
+        virtual ~ServerSocket();
+        
+    public:
+    
+        /**
+         * Bind and listen to given IP/dns and port.
+         * @param host IP address or host name.
+         * @param port TCP port between 1..655535
+         */
+        virtual void bind( const char* host, int port ) throw ( SocketException );
+    
+        /**
+         * Bind and listen to given IP/dns and port.
+         * @param host IP address or host name.
+         * @param port TCP port between 1..655535
+         * @param backlog Size of listen backlog.
+         */
+        virtual void bind( const char* host, int port, int backlog ) throw ( SocketException );
+    
+        /**
+         * Blocks until a client connects to the bound socket.
+         * @return new socket. Never returns NULL.
+         */
+        virtual Socket* accept () throw ( SocketException );
+    
+        /**
+         * Closes the server socket.
+         */
+        virtual void close() throw( cms::CMSException );
+    
+        /**
+         * @return true of the server socket is bound.
+         */ 
+        virtual bool isBound() const;
        
    protected:
 
@@ -94,18 +94,19 @@
               SocketException* socketInitError;
               
               void clear(){
-               if( socketInitError != NULL ){
-                  delete socketInitError;
-               }
-               socketInitError = NULL;
+                  if( socketInitError != NULL ){
+                      delete socketInitError;
+                  }
+                  socketInitError = NULL;
               }
               
           public:
-              SocketException* getSocketInitError () {
+          
+              SocketException* getSocketInitError() {
                   return socketInitError;
               }
               StaticServerSocketInitializer();
-              virtual ~StaticServerSocketInitializer ();
+              virtual ~StaticServerSocketInitializer();
                       
           };
           static StaticServerSocketInitializer staticSocketInitializer;

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/Socket.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/Socket.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/Socket.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/Socket.h Fri Jul 21 04:36:09 2006
@@ -29,141 +29,139 @@
 namespace activemq{
 namespace network{
 
-   class Socket : public cms::Closeable
-   {
-   public:
+    class Socket : public cms::Closeable
+    {
+    public:
    
-      // Define the SocketHandle type.
-      #if defined( unix ) || defined(__APPLE__) && !defined( __CYGWIN__ )
-          typedef int SocketHandle;
-      #else
-          typedef SOCKET SocketHandle;
-      #endif
-
-      /**
-       * Defines a constant for an invalid socket handle.
-       */   
-       static const SocketHandle INVALID_SOCKET_HANDLE = (SocketHandle) -1;
-
-   public:
-
-      /**
-       * Destructor
-       */
-   	virtual ~Socket(void) {}
-
-       /**
-       * 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 IOException Thrown if a failure occurred in the connect.
-       */
-      virtual void connect( const char* host, const int port ) 
-         throw(SocketException) = 0;
-      
-      /**
-       * Indicates whether or not this socket is connected to a destination.
-       */
-      virtual bool isConnected() const = 0;      
-
-      /**
-       * Gets the InputStream for this socket.
-       * @return The InputStream for this socket. NULL if not connected.
-       */
-      virtual io::InputStream* getInputStream() = 0;
-      
-      /**
-       * Gets the OutputStream for this socket.
-       * @return the OutputStream for this socket.  NULL if not connected.
-       */
-      virtual io::OutputStream* getOutputStream() = 0;
-
-      /**
-       * Gets the linger time.
-       * @return The linger time in seconds.
-       * @throws SocketException if the operation fails.
-       */
-      virtual int getSoLinger() const throw(SocketException) = 0;
-      
-      /**
-       * Sets the linger time.
-       * @param linger The linger time in seconds.  If 0, linger is off.
-       * @throws SocketException if the operation fails.
-       */
-      virtual void setSoLinger( const int linger ) throw(SocketException) = 0;
-      
-      /**
-       * Gets the keep alive flag.
-       * @return True if keep alive is enabled.
-       * @throws SocketException if the operation fails.
-       */
-      virtual bool getKeepAlive() const throw(SocketException) = 0;
-      
-      /**
-       * Enables/disables the keep alive flag.
-       * @param keepAlive If true, enables the flag.
-       * @throws SocketException if the operation fails.
-       */
-      virtual void setKeepAlive( const bool keepAlive ) throw(SocketException) = 0;
-      
-      /**
-       * Gets the receive buffer size.
-       * @return the receive buffer size in bytes.
-       * @throws SocketException if the operation fails.
-       */
-      virtual int getReceiveBufferSize() const throw(SocketException) = 0;
-      
-      /**
-       * Sets the recieve buffer size.
-       * @param size Number of bytes to set the receive buffer to.
-       * @throws SocketException if the operation fails.
-       */
-      virtual void setReceiveBufferSize( const int size ) throw(SocketException) = 0;
-      
-      /**
-       * Gets the reuse address flag.
-       * @return True if the address can be reused.
-       * @throws SocketException if the operation fails.
-       */
-      virtual bool getReuseAddress() const throw(SocketException) = 0;
-      
-      /**
-       * Sets the reuse address flag.
-       * @param reuse If true, sets the flag.
-       * @throws SocketException if the operation fails.
-       */
-      virtual void setReuseAddress( const bool reuse ) throw(SocketException) = 0;
-      
-      /**
-       * Gets the send buffer size.
-       * @return the size in bytes of the send buffer.
-       * @throws SocketException if the operation fails.
-       */
-      virtual int getSendBufferSize() const throw(SocketException) = 0;
-      
-      /**
-       * Sets the send buffer size.
-       * @param size The number of bytes to set the send buffer to.
-       * @throws SocketException if the operation fails.
-       */
-      virtual void setSendBufferSize( const int size ) throw(SocketException) = 0;
-      
-      /**
-       * Gets the timeout for socket operations.
-       * @return The timeout in milliseconds for socket operations.
-       * @throws SocketException Thrown if unable to retrieve the information.
-       */
-      virtual int getSoTimeout() const throw(SocketException) = 0;
-      
-      /**
-       * 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.
-       */
-      virtual void setSoTimeout( const int timeout ) throw(SocketException) = 0;
+        // Define the SocketHandle type.
+        #if defined( unix ) && !defined( __CYGWIN__ )
+            typedef int SocketHandle;
+        #else
+            typedef SOCKET SocketHandle;
+        #endif
+
+        /**
+         * Defines a constant for an invalid socket handle.
+         */   
+        static const SocketHandle INVALID_SOCKET_HANDLE = (SocketHandle) -1;
+
+    public:
+
+        virtual ~Socket(void) {}
+
+        /**
+         * 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 IOException Thrown if a failure occurred in the connect.
+         */
+        virtual void connect( const char* host, const int port ) 
+            throw(SocketException) = 0;
+      
+        /**
+         * Indicates whether or not this socket is connected to a destination.
+         * @returns true if connected
+         */
+        virtual bool isConnected() const = 0;      
+
+        /**
+         * Gets the InputStream for this socket.
+         * @return The InputStream for this socket. NULL if not connected.
+         */
+        virtual io::InputStream* getInputStream() = 0;
+      
+        /**
+         * Gets the OutputStream for this socket.
+         * @return the OutputStream for this socket.  NULL if not connected.
+         */
+        virtual io::OutputStream* getOutputStream() = 0;
+
+        /**
+         * Gets the linger time.
+         * @return The linger time in seconds.
+         * @throws SocketException if the operation fails.
+         */
+        virtual int getSoLinger() const throw( SocketException ) = 0;
+      
+        /**
+         * Sets the linger time.
+         * @param linger The linger time in seconds.  If 0, linger is off.
+         * @throws SocketException if the operation fails.
+         */
+        virtual void setSoLinger( const int linger ) throw( SocketException ) = 0;
+      
+        /**
+         * Gets the keep alive flag.
+         * @return True if keep alive is enabled.
+         * @throws SocketException if the operation fails.
+         */
+        virtual bool getKeepAlive() const throw( SocketException ) = 0;
+      
+        /**
+         * Enables/disables the keep alive flag.
+         * @param keepAlive If true, enables the flag.
+         * @throws SocketException if the operation fails.
+         */
+        virtual void setKeepAlive( const bool keepAlive ) throw( SocketException ) = 0;
+      
+        /**
+         * Gets the receive buffer size.
+         * @return the receive buffer size in bytes.
+         * @throws SocketException if the operation fails.
+         */
+        virtual int getReceiveBufferSize() const throw( SocketException ) = 0;
+      
+        /**
+         * Sets the recieve buffer size.
+         * @param size Number of bytes to set the receive buffer to.
+         * @throws SocketException if the operation fails.
+         */
+        virtual void setReceiveBufferSize( const int size ) throw( SocketException ) = 0;
+      
+        /**
+         * Gets the reuse address flag.
+         * @return True if the address can be reused.
+         * @throws SocketException if the operation fails.
+         */
+        virtual bool getReuseAddress() const throw( SocketException ) = 0;
+      
+        /**
+         * Sets the reuse address flag.
+         * @param reuse If true, sets the flag.
+         * @throws SocketException if the operation fails.
+         */
+        virtual void setReuseAddress( const bool reuse ) throw( SocketException ) = 0;
+      
+        /**
+         * Gets the send buffer size.
+         * @return the size in bytes of the send buffer.
+         * @throws SocketException if the operation fails.
+         */
+        virtual int getSendBufferSize() const throw( SocketException ) = 0;
+      
+        /**
+         * Sets the send buffer size.
+         * @param size The number of bytes to set the send buffer to.
+         * @throws SocketException if the operation fails.
+         */
+        virtual void setSendBufferSize( const int size ) throw( SocketException ) = 0;
+      
+        /**
+         * Gets the timeout for socket operations.
+         * @return The timeout in milliseconds for socket operations.
+         * @throws SocketException Thrown if unable to retrieve the information.
+         */
+        virtual int getSoTimeout() const throw( SocketException ) = 0;
+      
+        /**
+         * 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.
+         */
+        virtual void setSoTimeout( const int timeout ) throw( SocketException ) = 0;
 
-   };
+    };
 
 }}
 

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/SocketException.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/SocketException.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/SocketException.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/SocketException.h Fri Jul 21 04:36:09 2006
@@ -36,12 +36,12 @@
         SocketException( const SocketException& ex ){
             *(ActiveMQException*)this = ex;
         }
-	    SocketException(const char* file, const int lineNumber, 
-            const char* msg, ...)
+	    SocketException( const char* file, const int lineNumber, 
+                         const char* msg, ...)
 	    {
-	        va_list vargs ;
-            va_start(vargs, msg) ;
-            buildMessage(msg, vargs) ;
+	        va_list vargs;
+            va_start(vargs, msg);
+            buildMessage(msg, vargs);
             
             // Set the first mark for this exception.
             setMark( file, lineNumber );
@@ -57,7 +57,8 @@
         }
         
 	    virtual ~SocketException(){}
-	} ;
+        
+	};
 
 }}
 

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/SocketFactory.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/SocketFactory.cpp?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/SocketFactory.cpp (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/SocketFactory.cpp Fri Jul 21 04:36:09 2006
@@ -27,91 +27,91 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 Socket* SocketFactory::createSocket(const Properties& properties)
-   throw ( SocketException )
+    throw ( SocketException )
 {
-   try
-   {
-      const char* uri = properties.getProperty( "uri" );
-      if( uri == NULL )
-      {
-         throw SocketException( __FILE__, __LINE__, 
-               "SocketTransport::start() - uri not provided" );
-      }
+    try
+    {
+        const char* uri = properties.getProperty( "uri" );
+        if( uri == NULL )
+        {
+            throw SocketException( __FILE__, __LINE__, 
+                "SocketTransport::start() - uri not provided" );
+        }
 
-      string dummy = uri;
+        string dummy = uri;
       
-      // Extract the port.
-      unsigned int portIx = dummy.find( ':' );
-      if( portIx == string::npos )
-      {
-         throw SocketException( __FILE__, __LINE__, 
-            "SocketTransport::start() - uri malformed - port not specified: %s", uri);
-      }
-      string host = dummy.substr( 0, portIx );
-      string portString = dummy.substr( portIx + 1 );
-      int port;
-      if( sscanf( portString.c_str(), "%d", &port) != 1 )
-      {
-         throw SocketException( __FILE__, __LINE__, 
-            "SocketTransport::start() - unable to extract port from uri: %s", uri);
-      }
-      
-      // Get the read buffer size.
-      int inputBufferSize = 10000;
-      dummy = properties.getProperty( "inputBufferSize", "10000" );  
-      sscanf( dummy.c_str(), "%d", &inputBufferSize );
-      
-      // Get the write buffer size.
-      int outputBufferSize = 10000;
-      dummy = properties.getProperty( "outputBufferSize", "10000" ); 
-      sscanf( dummy.c_str(), "%d", &outputBufferSize );
-      
-      // Get the linger flag.
-      int soLinger = 0;
-      dummy = properties.getProperty( "soLinger", "0" ); 
-      sscanf( dummy.c_str(), "%d", &soLinger ); 
-      
-      // Get the keepAlive flag.
-      bool soKeepAlive = 
-         properties.getProperty( "soKeepAlive", "false" ) == "true";   
-      
-      // Get the socket receive buffer size.
-      int soReceiveBufferSize = 2000000;
-      dummy = properties.getProperty( "soReceiveBufferSize", "2000000" );  
-      sscanf( dummy.c_str(), "%d", &soReceiveBufferSize );
-      
-      // Get the socket send buffer size.
-      int soSendBufferSize = 2000000;
-      dummy = properties.getProperty( "soSendBufferSize", "2000000" );  
-      sscanf( dummy.c_str(), "%d", &soSendBufferSize );
-      
-      // Get the socket send buffer size.
-      int soTimeout = 10000;
-      dummy = properties.getProperty( "soTimeout", "10000" );  
-      sscanf( dummy.c_str(), "%d", &soTimeout );
-      
-      // Now that we have all the elements that we wanted - let's do it!
-      // Create a TCP Socket and then Wrap it in a buffered socket
-      // so that users get the benefit of buffered reads and writes.
-      // The buffered socket will own the TcpSocket instance, and will
-      // clean it up when it is cleaned up.
-      TcpSocket* tcpSocket = new TcpSocket();
-      BufferedSocket* socket = 
-         new BufferedSocket(tcpSocket, inputBufferSize, outputBufferSize);
-      
-      // Connect the socket.
-      socket->connect( host.c_str(), port );
-      
-      // Set the socket options.
-      socket->setSoLinger( soLinger );
-      socket->setKeepAlive( soKeepAlive );
-      socket->setReceiveBufferSize( soReceiveBufferSize );
-      socket->setSendBufferSize( soSendBufferSize );
-      socket->setSoTimeout( soTimeout );
+        // Extract the port.
+        unsigned int portIx = dummy.find( ':' );
+        if( portIx == string::npos )
+        {
+            throw SocketException( __FILE__, __LINE__, 
+                "SocketTransport::start() - uri malformed - port not specified: %s", uri);
+        }
+        string host = dummy.substr( 0, portIx );
+        string portString = dummy.substr( portIx + 1 );
+        int port;
+        if( sscanf( portString.c_str(), "%d", &port) != 1 )
+        {
+            throw SocketException( __FILE__, __LINE__, 
+               "SocketTransport::start() - unable to extract port from uri: %s", uri);
+        }
+      
+        // Get the read buffer size.
+        int inputBufferSize = 10000;
+        dummy = properties.getProperty( "inputBufferSize", "10000" );  
+        sscanf( dummy.c_str(), "%d", &inputBufferSize );
+      
+        // Get the write buffer size.
+        int outputBufferSize = 10000;
+        dummy = properties.getProperty( "outputBufferSize", "10000" ); 
+        sscanf( dummy.c_str(), "%d", &outputBufferSize );
+      
+        // Get the linger flag.
+        int soLinger = 0;
+        dummy = properties.getProperty( "soLinger", "0" ); 
+        sscanf( dummy.c_str(), "%d", &soLinger ); 
+      
+        // Get the keepAlive flag.
+        bool soKeepAlive = 
+            properties.getProperty( "soKeepAlive", "false" ) == "true";   
+      
+        // Get the socket receive buffer size.
+        int soReceiveBufferSize = 2000000;
+        dummy = properties.getProperty( "soReceiveBufferSize", "2000000" );  
+        sscanf( dummy.c_str(), "%d", &soReceiveBufferSize );
+      
+        // Get the socket send buffer size.
+        int soSendBufferSize = 2000000;
+        dummy = properties.getProperty( "soSendBufferSize", "2000000" );  
+        sscanf( dummy.c_str(), "%d", &soSendBufferSize );
+      
+        // Get the socket send buffer size.
+        int soTimeout = 10000;
+        dummy = properties.getProperty( "soTimeout", "10000" );  
+        sscanf( dummy.c_str(), "%d", &soTimeout );
+      
+        // Now that we have all the elements that we wanted - let's do it!
+        // Create a TCP Socket and then Wrap it in a buffered socket
+        // so that users get the benefit of buffered reads and writes.
+        // The buffered socket will own the TcpSocket instance, and will
+        // clean it up when it is cleaned up.
+        TcpSocket* tcpSocket = new TcpSocket();
+        BufferedSocket* socket = 
+            new BufferedSocket(tcpSocket, inputBufferSize, outputBufferSize);
+      
+        // Connect the socket.
+        socket->connect( host.c_str(), port );
+      
+        // Set the socket options.
+        socket->setSoLinger( soLinger );
+        socket->setKeepAlive( soKeepAlive );
+        socket->setReceiveBufferSize( soReceiveBufferSize );
+        socket->setSendBufferSize( soSendBufferSize );
+        socket->setSoTimeout( soTimeout );
 
-      return socket;
-   }
-   AMQ_CATCH_RETHROW( SocketException )
-   AMQ_CATCH_EXCEPTION_CONVERT( ActiveMQException, SocketException )
-   AMQ_CATCHALL_THROW( SocketException )   
+        return socket;
+    }
+    AMQ_CATCH_RETHROW( SocketException )
+    AMQ_CATCH_EXCEPTION_CONVERT( ActiveMQException, SocketException )
+    AMQ_CATCHALL_THROW( SocketException )   
 }

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/SocketFactory.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/SocketFactory.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/SocketFactory.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/SocketFactory.h Fri Jul 21 04:36:09 2006
@@ -23,45 +23,42 @@
 namespace activemq{
 namespace network{
 
-   class Socket;
+    class Socket;
    
-   /**
-    * Socket Factory implementation for use in Creating Sockets
-    * <p>
-    * <p>
-    * Property Options: <p>
-    * Name                  Value <p>
-    * ------------------------------------- <p>
-    * uri                   The uri for the transport connection. Must be provided.<p>
-    * inputBufferSize       size in bytes of the buffered input stream buffer.  Defaults to 10000.<p>
-    * outputBufferSize      size in bytes of the buffered output stream buffer. Defaults to 10000.<p>
-    * soLinger              linger time for the socket (in microseconds). Defaults to 0.<p>
-    * soKeepAlive           keep alive flag for the socket (true/false). Defaults to false.<p>
-    * soReceiveBufferSize   The size of the socket receive buffer (in bytes). Defaults to 2MB.<p>
-    * soSendBufferSize      The size of the socket send buffer (in bytes). Defaults to 2MB.<p>
-    * soTimeout             The timeout of socket IO operations (in microseconds). Defaults to 10000<p>
-    * 
-    * @see <code>Socket</code>
-    */
-   class SocketFactory
-   {
-   public:
+    /**
+     * Socket Factory implementation for use in Creating Sockets
+     * <p>
+     * <p>
+     * Property Options: <p>
+     * Name                  Value <p>
+     * ------------------------------------- <p>
+     * uri                   The uri for the transport connection. Must be provided.<p>
+     * inputBufferSize       size in bytes of the buffered input stream buffer.  Defaults to 10000.<p>
+     * outputBufferSize      size in bytes of the buffered output stream buffer. Defaults to 10000.<p>
+     * soLinger              linger time for the socket (in microseconds). Defaults to 0.<p>
+     * soKeepAlive           keep alive flag for the socket (true/false). Defaults to false.<p>
+     * soReceiveBufferSize   The size of the socket receive buffer (in bytes). Defaults to 2MB.<p>
+     * soSendBufferSize      The size of the socket send buffer (in bytes). Defaults to 2MB.<p>
+     * soTimeout             The timeout of socket IO operations (in microseconds). Defaults to 10000<p>
+     * 
+     * @see <code>Socket</code>
+     */
+    class SocketFactory
+    {
+    public:
 
-      /**
-       * Destructor
-       */
-   	virtual ~SocketFactory();
+   	    virtual ~SocketFactory();
       
-      /**
-       * Creates and returns a Socket dervied Object based on the values
-       * defined in the Properties Object that is passed in.
-       * @param a IProperties pointer.
-       * @throws SocketException.
-       */
-      static Socket* createSocket(const util::Properties& properties)
-         throw ( SocketException );
+        /**
+         * Creates and returns a Socket dervied Object based on the values
+         * defined in the Properties Object that is passed in.
+         * @param a IProperties pointer.
+         * @throws SocketException.
+         */
+        static Socket* createSocket( const util::Properties& properties )
+            throw ( SocketException );
          
-   };
+    };
 
 }}
 

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/SocketInputStream.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/SocketInputStream.cpp?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/SocketInputStream.cpp (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/SocketInputStream.cpp Fri Jul 21 04:36:09 2006
@@ -16,12 +16,12 @@
  */
  
 #if (defined(unix) || defined(__APPLE__)) && !defined(__CYGWIN__)
-   #include <sys/poll.h>
-   #include <sys/socket.h>
-   #include <errno.h>
-   extern int errno;
+    #include <sys/poll.h>
+    #include <sys/socket.h>
+    #include <errno.h>
+    extern int errno;
 #else
-   #include <Winsock2.h>
+    #include <Winsock2.h>
 #endif
 
 #include <activemq/network/SocketInputStream.h>
@@ -50,7 +50,7 @@
 int SocketInputStream::available() const{
    
    
-#if (defined(unix) || defined(__APPLE__)) && !defined(__CYGWIN__)
+#if defined(unix) && !defined(__CYGWIN__)
     
     // Poll the socket for input.
     pollfd fd;
@@ -121,7 +121,7 @@
             
                 // If the socket was temporarily unavailable - just try again.
                 int errorCode = ::WSAGetLastError();
-                if( errorCode == WSAEWOULDBLOCK ){
+                if( errorCode == WSAEWOULDBLOCK || errorCode == WSAETIMEDOUT ){
                     continue;
                 }
           



Mime
View raw message