public SocketToken(int id, Sinan.Collections.BytesSegment receiveBuffer, Sinan.Collections.BytesSegment sendBuffer, IBufferProcessor processor, Collections.CircularQueue<Collections.BytesSegment> sendPool = null) { m_connectID = id; m_sendPool = sendPool ?? new Collections.CircularQueue<Collections.BytesSegment>(64); m_processor = processor; SocketAsyncEventArgs receiver = new SocketAsyncEventArgs(); receiver.Completed += new EventHandler<SocketAsyncEventArgs>(ReceiveCompleted); receiver.SetBuffer(receiveBuffer.Array, receiveBuffer.Offset, receiveBuffer.Count); SocketAsyncEventArgs sender = new SocketAsyncEventArgs(); sender.Completed += new EventHandler<SocketAsyncEventArgs>(SendCompleted); sender.SetBuffer(sendBuffer.Array, sendBuffer.Offset, sendBuffer.Count); m_receiver = receiver; m_receiveOffset = receiver.Offset; m_receiveMax = receiver.Count; m_sender = sender; m_sendOffset = sender.Offset; m_sendMax = sender.Count; }
internal UserBuffer(int id, SessionFactory f, Sinan.Collections.BytesSegment r, Sinan.Collections.BytesSegment s, int sendQueueSize = 64) { this.factory = f; this.BufferID = id; this.ReceiveBuffer = r; this.SendBuffer = s; this.SendPool = new Sinan.Collections.CircularQueue<Sinan.Collections.BytesSegment>(sendQueueSize); }
public virtual void Close() { if (m_socketInUse < 2) { Thread.VolatileWrite(ref m_socketInUse, 2); } Socket client = null; lock (m_locker) { if (m_socket != null) { client = m_socket; m_socket = null; m_sendPool = null; m_curBuff = null; } } if (client != null) { m_written = 0; client.SafeClose(); } }