示例#1
0
        internal IAsyncResult BeginMultipleWrite(BufferOffsetSize[] buffers, AsyncCallback callback, object state)
        {
#if TRAVE
            for (int i = 0; i < buffers.Length; ++i)
            {
                GlobalLog.Dump(buffers[i].Buffer, buffers[i].Offset, buffers[i].Size);
            }
#endif
            return(m_NetworkStream.BeginMultipleWrite(buffers, callback, state));
        }
示例#2
0
        //
        //
        //
        //
        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);
        }
 internal IAsyncResult BeginMultipleWrite(BufferOffsetSize[] buffers, AsyncCallback callback, object state)
 {
     return(m_NetworkStream.BeginMultipleWrite(buffers, callback, state));
 }