Beispiel #1
0
 public virtual void streamWriteImpl(BasicStream s)
 {
     s.writeString(host_);
     s.writeInt(port_);
 }
Beispiel #2
0
 //
 // Marshal the endpoint
 //
 public override void streamWrite(BasicStream s)
 {
     s.writeShort(Ice.TCPEndpointType.value);
     s.startWriteEncaps();
     s.writeString(_host);
     s.writeInt(_port);
     s.writeInt(_timeout);
     s.writeBool(_compress);
     s.endWriteEncaps();
 }
Beispiel #3
0
 public override void streamWriteImpl(BasicStream s)
 {
     base.streamWriteImpl(s);
     s.writeInt(_timeout);
     s.writeBool(_compress);
 }
Beispiel #4
0
 //
 // Marshal the endpoint
 //
 public override void streamWrite(BasicStream s)
 {
     s.writeShort(Ice.UDPEndpointType.value);
     s.startWriteEncaps();
     s.writeString(_host);
     s.writeInt(_port);
     if(s.getWriteEncoding().Equals(Ice.Util.Encoding_1_0))
     {
         Ice.Util.Protocol_1_0.write__(s);
         Ice.Util.Encoding_1_0.write__(s);
     }
     // Not transmitted.
     //s.writeBool(_connect);
     s.writeBool(_compress);
     s.endWriteEncaps();
 }
Beispiel #5
0
 //
 // Marshal the endpoint
 //
 public override void streamWrite(BasicStream s)
 {
     s.writeShort(Ice.UDPEndpointType.value);
     s.startWriteEncaps();
     s.writeString(_host);
     s.writeInt(_port);
     s.writeByte(_protocolMajor);
     s.writeByte(_protocolMinor);
     s.writeByte(_encodingMajor);
     s.writeByte(_encodingMinor);
     // Not transmitted.
     //s.writeBool(_connect);
     s.writeBool(_compress);
     s.endWriteEncaps();
 }
Beispiel #6
0
        public bool compress(ref BasicStream cstream, int headerSize, int compressionLevel)
        {
            #if MANAGED || COMPACT
            cstream = this;
            return false;
            #else
            if(!_bzlibInstalled)
            {
                cstream = this;
                return false;
            }

            //
            // Compress the message body, but not the header.
            //
            int uncompressedLen = size() - headerSize;
            byte[] uncompressed = _buf.b.rawBytes(headerSize, uncompressedLen);
            int compressedLen = (int)(uncompressedLen * 1.01 + 600);
            byte[] compressed = new byte[compressedLen];

            int rc = NativeMethods.BZ2_bzBuffToBuffCompress(compressed, ref compressedLen, uncompressed,
                                                            uncompressedLen, compressionLevel, 0, 0);
            if(rc == BZ_OUTBUFF_FULL)
            {
                cstream = null;
                return false;
            }
            else if(rc < 0)
            {
                Ice.CompressionException ex = new Ice.CompressionException("BZ2_bzBuffToBuffCompress failed");
                ex.reason = getBZ2Error(rc);
                throw ex;
            }

            //
            // Don't bother if the compressed data is larger than the
            // uncompressed data.
            //
            if(compressedLen >= uncompressedLen)
            {
                return false;
            }

            cstream = new BasicStream(instance_);
            cstream.resize(headerSize + 4 + compressedLen, false);
            cstream.pos(0);

            //
            // Copy the header from the uncompressed stream to the
            // compressed one.
            //
            cstream._buf.b.put(_buf.b.rawBytes(0, headerSize));

            //
            // Add the size of the uncompressed stream before the
            // message body.
            //
            cstream.writeInt(size());

            //
            // Add the compressed message body.
            //
            cstream._buf.b.put(compressed, 0, compressedLen);

            return true;
            #endif
        }