internal void PrepareReceive() { if (Buffer == null || Buffer.Buffer.Length - Buffer.WriteIndex < 2048) { if (Buffer != null) { Buffer.BusyReceiving = false; Buffer.FreeBuffer(); } SocketBuffer socketBuffer; if (BufferManager.GetFreeOrNewBuffer(out socketBuffer)) { Buffer = socketBuffer; Buffer.BusyReceiving = true; } } SocketEventArgs.SetBuffer((int)Buffer.WriteIndex, (int)(Buffer.Buffer.Length - Buffer.WriteIndex)); SocketEventArgs.UserToken = this; // Do other necessary markings here. }