예제 #1
0
파일: MsgBlob.cs 프로젝트: erdincay/db4o
		/// <exception cref="System.IO.IOException"></exception>
		protected virtual void Copy(Socket4Adapter sock, IOutputStream rawout, int length
			, bool update)
		{
			BufferedOutputStream @out = new BufferedOutputStream(rawout);
			byte[] buffer = new byte[BlobImpl.CopybufferLength];
			int totalread = 0;
			while (totalread < length)
			{
				int stilltoread = length - totalread;
				int readsize = (stilltoread < buffer.Length ? stilltoread : buffer.Length);
				int 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();
		}
예제 #2
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;
		}