当前位置: 首页>>代码示例>>C#>>正文


C# Net.BufferOffsetSize类代码示例

本文整理汇总了C#中System.Net.BufferOffsetSize的典型用法代码示例。如果您正苦于以下问题:C# BufferOffsetSize类的具体用法?C# BufferOffsetSize怎么用?C# BufferOffsetSize使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BufferOffsetSize类属于System.Net命名空间,在下文中一共展示了BufferOffsetSize类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SplitWritesState

 internal SplitWritesState(BufferOffsetSize[] buffers)
 {
     this._UserBuffers = buffers;
     this._LastBufferConsumed = 0;
     this._Index = 0;
     this._RealBuffers = null;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:SplitWritesState.cs

示例2: BeginMultipleWrite

 internal override IAsyncResult BeginMultipleWrite(BufferOffsetSize[] buffers, AsyncCallback callback, object state)
 {
     IAsyncResult result2;
     if (!this.m_Worker.IsAuthenticated)
     {
         BufferAsyncResult result = new BufferAsyncResult(this, buffers, state, callback);
         if (this.ProcessAuthentication(result))
         {
             return result;
         }
     }
     try
     {
         result2 = this.m_Worker.SecureStream.BeginWrite(buffers, callback, state);
     }
     catch
     {
         if (this.m_Worker.IsCertValidationFailed)
         {
             this.m_ExceptionStatus = WebExceptionStatus.TrustFailure;
         }
         else if (this.m_Worker.LastSecurityStatus != SecurityStatus.OK)
         {
             this.m_ExceptionStatus = WebExceptionStatus.SecureChannelFailure;
         }
         else
         {
             this.m_ExceptionStatus = WebExceptionStatus.SendFailure;
         }
         throw;
     }
     return result2;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:33,代码来源:TlsStream.cs

示例3: BeginWrite

 internal IAsyncResult BeginWrite(BufferOffsetSize[] buffers, AsyncCallback asyncCallback, object asyncState)
 {
     LazyAsyncResult userAsyncResult = new LazyAsyncResult(this, asyncState, asyncCallback);
     SplitWriteAsyncProtocolRequest asyncRequest = new SplitWriteAsyncProtocolRequest(userAsyncResult);
     this.ProcessWrite(buffers, asyncRequest);
     return userAsyncResult;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:_SslStream.cs

示例4: NestedMultipleAsyncResult

 internal NestedMultipleAsyncResult(object asyncObject, object asyncState, AsyncCallback asyncCallback, BufferOffsetSize[] buffers) : base(asyncObject, asyncState, asyncCallback)
 {
     this.Buffers = buffers;
     this.Size = 0;
     for (int i = 0; i < this.Buffers.Length; i++)
     {
         this.Size += this.Buffers[i].Size;
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:9,代码来源:NestedMultipleAsyncResult.cs

示例5: GetBuffers

 internal BufferOffsetSize[] GetBuffers()
 {
     if (this.Empty)
     {
         return null;
     }
     BufferOffsetSize[] sizeArray = new BufferOffsetSize[this.chunkCount];
     int index = 0;
     for (MemoryChunk chunk = this.headChunk; chunk != null; chunk = chunk.Next)
     {
         sizeArray[index] = new BufferOffsetSize(chunk.Buffer, 0, chunk.FreeOffset, false);
         index++;
     }
     return sizeArray;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:15,代码来源:ScatterGatherBuffers.cs

示例6: SetUnmanagedStructures

 internal void SetUnmanagedStructures(BufferOffsetSize[] buffers)
 {
     this.m_WSABuffers = new WSABuffer[buffers.Length];
     object[] objectsToPin = new object[buffers.Length];
     for (int i = 0; i < buffers.Length; i++)
     {
         objectsToPin[i] = buffers[i].Buffer;
     }
     base.SetUnmanagedStructures(objectsToPin);
     for (int j = 0; j < buffers.Length; j++)
     {
         this.m_WSABuffers[j].Length = buffers[j].Size;
         this.m_WSABuffers[j].Pointer = Marshal.UnsafeAddrOfPinnedArrayElement(buffers[j].Buffer, buffers[j].Offset);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:15,代码来源:OverlappedAsyncResult.cs

示例7: GetBuffers

 public BufferOffsetSize[] GetBuffers() {
     if (Empty) {
         return null;
     }
     GlobalLog.Print("ScatterGatherBuffers#" + ValidationHelper.HashString(this) + "::ToArray() chunkCount:" + chunkCount.ToString());
     BufferOffsetSize[] array = new BufferOffsetSize[chunkCount];
     int index = 0;
     MemoryChunk thisMemoryChunk = headChunk;
     while (thisMemoryChunk!=null) {
         GlobalLog.Print("ScatterGatherBuffers#" + ValidationHelper.HashString(this) + "::ToArray() index:" + index.ToString() + " size:" + thisMemoryChunk.FreeOffset);
         //
         // buffer itself is referenced by the BufferOffsetSize struct, data is not copied
         //
         array[index] = new BufferOffsetSize(thisMemoryChunk.Buffer, 0, thisMemoryChunk.FreeOffset, false);
         index++;
         thisMemoryChunk = thisMemoryChunk.Next;
     }
     return array;
 }
开发者ID:ArildF,项目名称:masters,代码行数:19,代码来源:_scattergatherbuffers.cs

示例8: SetUnmanagedStructures

        internal void SetUnmanagedStructures(BufferOffsetSize[] buffers)
        {
            // Fill in Buffer Array structure that will be used for our send/recv Buffer
            _wsaBuffers = new WSABuffer[buffers.Length];

            object[] objectsToPin = new object[buffers.Length];
            for (int i = 0; i < buffers.Length; i++)
            {
                objectsToPin[i] = buffers[i].Buffer;
            }

            // has to be called now to pin memory
            base.SetUnmanagedStructures(objectsToPin);

            for (int i = 0; i < buffers.Length; i++)
            {
                _wsaBuffers[i].Length = buffers[i].Size;
                _wsaBuffers[i].Pointer = Marshal.UnsafeAddrOfPinnedArrayElement(buffers[i].Buffer, buffers[i].Offset);
            }
        }
开发者ID:nnyamhon,项目名称:corefx,代码行数:20,代码来源:_OverlappedAsyncResult.Windows.cs

示例9: MultipleSend

        internal void MultipleSend(BufferOffsetSize[] buffers, SocketFlags socketFlags) {
            if(s_LoggingEnabled)Logging.Enter(Logging.Sockets, this, "MultipleSend", "");
            if (CleanedUp) {
                throw new ObjectDisposedException(this.GetType().FullName);
            }
            //
            // parameter validation
            //
            GlobalLog.Assert(buffers != null, "Socket#{0}::MultipleSend()|buffers == null", ValidationHelper.HashString(this));
            GlobalLog.Print("Socket#" + ValidationHelper.HashString(this) + "::MultipleSend() buffers.Length:" + buffers.Length.ToString());

            WSABuffer[] WSABuffers = new WSABuffer[buffers.Length];
            GCHandle[] objectsToPin = null;
            int bytesTransferred;
            SocketError errorCode;

            try {
                objectsToPin = new GCHandle[buffers.Length];
                for (int i = 0; i < buffers.Length; ++i)
                {
                    objectsToPin[i] = GCHandle.Alloc(buffers[i].Buffer, GCHandleType.Pinned);
                    WSABuffers[i].Length = buffers[i].Size;
                    WSABuffers[i].Pointer = Marshal.UnsafeAddrOfPinnedArrayElement(buffers[i].Buffer, buffers[i].Offset);
                }

                // This can throw ObjectDisposedException.
                errorCode = UnsafeNclNativeMethods.OSSOCK.WSASend_Blocking(
                    m_Handle.DangerousGetHandle(),
                    WSABuffers,
                    WSABuffers.Length,
                    out bytesTransferred,
                    socketFlags,
                    SafeNativeOverlapped.Zero,
                    IntPtr.Zero);

                GlobalLog.Print("Socket#" + ValidationHelper.HashString(this) + "::MultipleSend() UnsafeNclNativeMethods.OSSOCK.WSASend returns:" + errorCode.ToString() + " size:" + buffers.Length.ToString());

            }
            finally {
                if (objectsToPin != null)
                    for (int i = 0; i < objectsToPin.Length; ++i)
                        if (objectsToPin[i].IsAllocated)
                            objectsToPin[i].Free();
            }

            if (errorCode!=SocketError.Success) {
                SocketException socketException = new SocketException();
                UpdateStatusAfterSocketError(socketException);
                if(s_LoggingEnabled)Logging.Exception(Logging.Sockets, this, "MultipleSend", socketException);
                throw socketException;
            }

            if(s_LoggingEnabled)Logging.Exit(Logging.Sockets, this, "MultipleSend", "");
        }
开发者ID:REALTOBIZ,项目名称:mono,代码行数:54,代码来源:Socket.cs

示例10: BeginWriteMessage

        //
        //
        //
        //
        public IAsyncResult BeginWriteMessage(byte[] message, AsyncCallback asyncCallback, object stateObject) {
            if (message == null) {
                throw new ArgumentNullException("message");
            }

            m_WriteHeader.PayloadSize = message.Length;
            m_WriteHeader.CopyTo(m_WriteHeaderBuffer, 0);

            if (m_NetworkStream != null && message.Length != 0) {
                BufferOffsetSize[] buffers = new BufferOffsetSize[2];
                buffers[0] = new BufferOffsetSize(m_WriteHeaderBuffer, 0, m_WriteHeaderBuffer.Length, false);
                buffers[1] = new BufferOffsetSize(message, 0, message.Length, false);
                return m_NetworkStream.BeginMultipleWrite(buffers, asyncCallback, stateObject);
            }

            if (message.Length == 0) {
                return Transport.BeginWrite(m_WriteHeaderBuffer, 0, m_WriteHeaderBuffer.Length,
                                                   asyncCallback, stateObject);
            }
            //Will need two async writes
            // Prepare the second
            WorkerAsyncResult workerResult = new WorkerAsyncResult(this, stateObject, asyncCallback,
                                                                   message, 0, message.Length);
            // Charge the first
            IAsyncResult result = Transport.BeginWrite(m_WriteHeaderBuffer, 0, m_WriteHeaderBuffer.Length,
                                 m_BeginWriteCallback, workerResult);
            if (result.CompletedSynchronously)
            {
                BeginWriteComplete(result);
            }

            return workerResult;
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:37,代码来源:_StreamFramer.cs

示例11: WriteMessage

        //
        //
        //
        //
        public void WriteMessage(byte[] message) {
            if (message == null) {
                throw new ArgumentNullException("message");
            }
            m_WriteHeader.PayloadSize = message.Length;
            m_WriteHeader.CopyTo(m_WriteHeaderBuffer, 0);

            if (m_NetworkStream != null && message.Length != 0) {
                BufferOffsetSize[] buffers = new BufferOffsetSize[2];
                buffers[0] = new BufferOffsetSize(m_WriteHeaderBuffer, 0, m_WriteHeaderBuffer.Length, false);
                buffers[1] = new BufferOffsetSize(message, 0, message.Length, false);
                m_NetworkStream.MultipleWrite(buffers);
            }
            else {
                Transport.Write(m_WriteHeaderBuffer, 0, m_WriteHeaderBuffer.Length);
                if (message.Length==0) {
                    return;
                }
                Transport.Write(message, 0, message.Length);
            }
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:25,代码来源:_StreamFramer.cs

示例12: UnsafeBeginMultipleWrite

 internal override IAsyncResult UnsafeBeginMultipleWrite(BufferOffsetSize[] buffers, AsyncCallback callback, object state) {
     return BeginMultipleWrite(buffers,callback,state);
 }
开发者ID:REALTOBIZ,项目名称:mono,代码行数:3,代码来源:_TLSstream.cs

示例13: MultipleSend

 internal void MultipleSend(BufferOffsetSize[] buffers, SocketFlags socketFlags)
 {
     if (Socket.s_LoggingEnabled)
     Logging.Enter(Logging.Sockets, (object) this, "MultipleSend", "");
       if (this.CleanedUp)
     throw new ObjectDisposedException(this.GetType().FullName);
       WSABuffer[] buffersArray = new WSABuffer[buffers.Length];
       GCHandle[] gcHandleArray = (GCHandle[]) null;
       SocketError socketError;
       try
       {
     gcHandleArray = new GCHandle[buffers.Length];
     for (int index = 0; index < buffers.Length; ++index)
     {
       gcHandleArray[index] = GCHandle.Alloc((object) buffers[index].Buffer, GCHandleType.Pinned);
       buffersArray[index].Length = buffers[index].Size;
       buffersArray[index].Pointer = Marshal.UnsafeAddrOfPinnedArrayElement((Array) buffers[index].Buffer, buffers[index].Offset);
     }
     int bytesTransferred;
     socketError = UnsafeNclNativeMethods.OSSOCK.WSASend_Blocking(this.m_Handle.DangerousGetHandle(), buffersArray, buffersArray.Length, out bytesTransferred, socketFlags, (SafeHandle) SafeNativeOverlapped.Zero, IntPtr.Zero);
       }
       finally
       {
     if (gcHandleArray != null)
     {
       for (int index = 0; index < gcHandleArray.Length; ++index)
       {
     if (gcHandleArray[index].IsAllocated)
       gcHandleArray[index].Free();
       }
     }
       }
       if (socketError != SocketError.Success)
       {
     SocketException socketException = new SocketException();
     this.UpdateStatusAfterSocketError(socketException);
     if (Socket.s_LoggingEnabled)
       Logging.Exception(Logging.Sockets, (object) this, "MultipleSend", (Exception) socketException);
     throw socketException;
       }
       else
       {
     if (!Socket.s_LoggingEnabled)
       return;
     Logging.Exit(Logging.Sockets, (object) this, "MultipleSend", "");
       }
 }
开发者ID:korifey,项目名称:hackathon-Ideaphone,代码行数:47,代码来源:Socket.cs

示例14: SendAsync

 public static SocketError SendAsync(SafeCloseSocket handle, BufferOffsetSize[] buffers, SocketFlags socketFlags, OverlappedAsyncResult asyncResult)
 {
     return handle.AsyncContext.SendAsync(new BufferList(buffers), GetPlatformSocketFlags(socketFlags), asyncResult.CompletionCallback);
 }
开发者ID:nnyamhon,项目名称:corefx,代码行数:4,代码来源:SocketPal.Unix.cs

示例15: DoBeginMultipleSend

        private void DoBeginMultipleSend(BufferOffsetSize[] buffers, SocketFlags socketFlags, OverlappedAsyncResult asyncResult)
        {
            if(s_LoggingEnabled)Logging.Enter(Logging.Sockets, this, "BeginMultipleSend", "");
            if (CleanedUp) {
                throw new ObjectDisposedException(this.GetType().FullName);
            }
            //
            // parameter validation
            //
            GlobalLog.Assert(buffers != null, "Socket#{0}::DoBeginMultipleSend()|buffers == null", ValidationHelper.HashString(this));
            GlobalLog.Print("Socket#" + ValidationHelper.HashString(this) + "::DoBeginMultipleSend() buffers.Length:" + buffers.Length.ToString());

            // Guarantee to call CheckAsyncCallOverlappedResult if we call SetUnamangedStructures with a cache in order to
            // avoid a Socket leak in case of error.
            SocketError errorCode = SocketError.SocketError;
            try
            {
                // Set up asyncResult for overlapped WSASend.
                // This call will use completion ports on WinNT and Overlapped IO on Win9x.
                asyncResult.SetUnmanagedStructures(buffers, ref Caches.SendOverlappedCache);

                // This can throw ObjectDisposedException.
                int bytesTransferred;
                errorCode = UnsafeNclNativeMethods.OSSOCK.WSASend(
                    m_Handle,
                    asyncResult.m_WSABuffers,
                    asyncResult.m_WSABuffers.Length,
                    out bytesTransferred,
                    socketFlags,
                    asyncResult.OverlappedHandle,
                    IntPtr.Zero);

                if (errorCode!=SocketError.Success) {
                    errorCode = (SocketError)Marshal.GetLastWin32Error();
                }
                GlobalLog.Print("Socket#" + ValidationHelper.HashString(this) + "::BeginMultipleSend() UnsafeNclNativeMethods.OSSOCK.WSASend returns:" + errorCode.ToString() + " size:" + buffers.Length.ToString() + " returning AsyncResult:" + ValidationHelper.HashString(asyncResult));
            }
            finally
            {
                errorCode = asyncResult.CheckAsyncCallOverlappedResult(errorCode);
            }

            //
            // if the asynchronous native call fails synchronously
            // we'll throw a SocketException
            //
            if (errorCode!=SocketError.Success) {
                //
                // update our internal state after this socket error and throw
                //
                asyncResult.ExtractCache(ref Caches.SendOverlappedCache);
                SocketException socketException = new SocketException(errorCode);
                UpdateStatusAfterSocketError(socketException);
                if(s_LoggingEnabled)Logging.Exception(Logging.Sockets, this, "BeginMultipleSend", socketException);
                throw socketException;
           }
            if(s_LoggingEnabled)Logging.Exit(Logging.Sockets, this, "BeginMultipleSend", asyncResult);
        }
开发者ID:REALTOBIZ,项目名称:mono,代码行数:58,代码来源:Socket.cs


注:本文中的System.Net.BufferOffsetSize类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。