public override void Flush() { //byte[] buf = writeBuffer.GetBuffer(); byte[] buf = null; ArraySegment <byte> _buf; bool flag = writeBuffer.TryGetBuffer(out _buf); if (flag) { buf = _buf.Array; } //byte[] buf = _buf.Array; int len = (int)writeBuffer.Length; int data_len = len - header_size; if (data_len < 0) { throw new System.InvalidOperationException(); // logic error actually } InitWriteBuffer(); // Inject message header into the reserved buffer space EncodeFrameSize(data_len, ref buf); // Send the entire message at once transport.Write(buf, 0, len); transport.Flush(); }
public override void Flush() { CheckNotDisposed(); InternalFlush(); transport.Flush(); }
public override void Flush() { byte[] buf; #if NET_CORE ArraySegment <byte> arraySegment; buf = writeBuffer.TryGetBuffer(out arraySegment) ? arraySegment.Array : writeBuffer.ToArray(); #else buf = writeBuffer.GetBuffer(); #endif int len = (int)writeBuffer.Length; int data_len = len - header_size; if (data_len < 0) { throw new System.InvalidOperationException(); // logic error actually } InitWriteBuffer(); // Inject message header into the reserved buffer space EncodeFrameSize(data_len, ref buf); // Send the entire message at once transport.Write(buf, 0, len); transport.Flush(); }
public override void Flush() { CheckNotDisposed(); if (!IsOpen) { throw new TTransportException(TTransportException.ExceptionType.NotOpen); } byte[] buf = writeBuffer.GetBuffer(); int len = (int)writeBuffer.Length; int data_len = len - HeaderSize; if (data_len < 0) { throw new System.InvalidOperationException(); // logic error actually } // Inject message header into the reserved buffer space EncodeFrameSize(data_len, buf); // Send the entire message at once transport.Write(buf, 0, len); InitWriteBuffer(); transport.Flush(); }
public override void Flush() { CheckNotDisposed(); if (!IsOpen) { throw new TTransportException(TTransportException.ExceptionType.NotOpen); } if (outputBuffer.Length > 0) { transport.Write(outputBuffer.GetBuffer(), 0, (int)outputBuffer.Length); outputBuffer.SetLength(0); } transport.Flush(); }
public override void Flush() { byte[] buf = writeBuffer.GetBuffer(); int len = (int)writeBuffer.Length; writeBuffer = new MemoryStream(writeBuffer.Capacity); byte[] i32out = new byte[4]; i32out[0] = (byte)(0xff & (len >> 24)); i32out[1] = (byte)(0xff & (len >> 16)); i32out[2] = (byte)(0xff & (len >> 8)); i32out[3] = (byte)(0xff & (len)); transport.Write(i32out, 0, 4); transport.Write(buf, 0, len); transport.Flush(); }
public override void Flush() { byte[] buf = writeBuffer.GetBuffer(); int len = (int)writeBuffer.Length; int data_len = len - header_size; if (data_len < 0) { throw new System.InvalidOperationException(); // logic error actually } InitWriteBuffer(); // Inject message header into the reserved buffer space buf[0] = (byte)(0xff & (data_len >> 24)); buf[1] = (byte)(0xff & (data_len >> 16)); buf[2] = (byte)(0xff & (data_len >> 8)); buf[3] = (byte)(0xff & (data_len)); // Send the entire message at once transport.Write(buf, 0, len); transport.Flush(); }
private void DestoryInstance(TTransport instance) { if (instance.IsOpen) { instance.Close(); } instance.Flush(); instance.Dispose(); }
/// <summary> /// Close Connection /// </summary> /// <param name="transport">Exists Connect</param> public static void TransportClose(ref TTransport transport) { transport.Flush(); transport.Close(); }