Esempio n. 1
0
 /// <exception cref="System.IO.IOException"></exception>
 protected virtual void Copy(Socket4Adapter sock, IOutputStream rawout, int length
     , bool update)
 {
     var @out = new BufferedOutputStream(rawout);
     var buffer = new byte[BlobImpl.CopybufferLength];
     var totalread = 0;
     while (totalread < length)
     {
         var stilltoread = length - totalread;
         var readsize = (stilltoread < buffer.Length ? stilltoread : buffer.Length);
         var curread = sock.Read(buffer, 0, readsize);
         if (curread < 0)
         {
             throw new IOException();
         }
         @out.Write(buffer, 0, curread);
         totalread += curread;
         if (update)
         {
             _currentByte += curread;
         }
     }
     @out.Flush();
     @out.Close();
 }
Esempio n. 2
0
        /// <exception cref="System.IO.IOException"></exception>
        protected virtual void Copy(Socket4Adapter sock, IOutputStream rawout, int length
                                    , bool update)
        {
            var @out      = new BufferedOutputStream(rawout);
            var buffer    = new byte[BlobImpl.CopybufferLength];
            var totalread = 0;

            while (totalread < length)
            {
                var stilltoread = length - totalread;
                var readsize    = (stilltoread < buffer.Length ? stilltoread : buffer.Length);
                var curread     = sock.Read(buffer, 0, readsize);
                if (curread < 0)
                {
                    throw new IOException();
                }
                @out.Write(buffer, 0, curread);
                totalread += curread;
                if (update)
                {
                    _currentByte += curread;
                }
            }
            @out.Flush();
            @out.Close();
        }
Esempio n. 3
0
        /// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
        protected static StatefulBuffer ReadMessageBuffer(Db4objects.Db4o.Internal.Transaction
                                                          trans, Socket4Adapter socket, int length)
        {
            StatefulBuffer buffer = new StatefulBuffer(trans, length);
            int            offset = 0;

            while (length > 0)
            {
                int read = socket.Read(buffer._buffer, offset, length);
                if (read < 0)
                {
                    throw new Db4oIOException();
                }
                offset += read;
                length -= read;
            }
            return(buffer);
        }
Esempio n. 4
0
File: Msg.cs Progetto: masroore/db4o
 /// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
 protected static StatefulBuffer ReadMessageBuffer(Transaction
     trans, Socket4Adapter socket, int length)
 {
     var buffer = new StatefulBuffer(trans, length);
     var offset = 0;
     while (length > 0)
     {
         var read = socket.Read(buffer._buffer, offset, length);
         if (read < 0)
         {
             throw new Db4oIOException();
         }
         offset += read;
         length -= read;
     }
     return buffer;
 }