protected virtual void Dispose(bool disposing) { if (m_disposed) { return; } //if (disposing) { } m_handlerDisconnected = null; m_handlerReceived = null; m_saeaReciver = null; m_saeaSender = null; m_pooledBufferManager = null; m_queueSend = null; m_listSend.Clear(); m_listSend = null; m_bClosed = null; m_bClosing = null; m_bSending = null; m_bReceiving = null; m_disposed = true; }
public void Uninitialize() { m_config = null; m_bufferManager = null; m_pooledBufferManager = null; m_poolRecvSAEA = null; m_poolSendSAEA = null; }
public bool Initialize(ServerConfig config) { m_config = config; int[] poolSizes = new int[] { 4096, 16, 128, 256, 1024, }; // size를 재설정 해보자. m_pooledBufferManager = new PooledBufferManager(poolSizes); int bufferSize = m_nReceiveBufferSize; m_bufferManager = new BufferManager(bufferSize * m_config.m_nMaxConnection, bufferSize); m_bufferManager.InitBuffer(); try { { SocketAsyncEventArgs socketEventArg; var socketArgsList = new List <SocketAsyncEventArgs>(m_config.m_nMaxConnection); for (int i = 0; i < m_config.m_nMaxConnection; i++) { socketEventArg = new SocketAsyncEventArgs(); socketEventArg.Completed += new EventHandler <SocketAsyncEventArgs>(CompletedReceive); m_bufferManager.SetBuffer(socketEventArg); socketArgsList.Add(socketEventArg); } m_poolRecvSAEA = new ConcurrentStack <SocketAsyncEventArgs>(socketArgsList); } { SocketAsyncEventArgs socketEventArg; var socketArgsList = new List <SocketAsyncEventArgs>(m_config.m_nMaxConnection); for (int i = 0; i < m_config.m_nMaxConnection; i++) { socketEventArg = new SocketAsyncEventArgs(); socketEventArg.Completed += new EventHandler <SocketAsyncEventArgs>(CompletedSend); socketEventArg.SetBuffer(null, 0, 0); // Send 할때 pooledBufferManager를 이용한다. socketArgsList.Add(socketEventArg); } m_poolSendSAEA = new ConcurrentStack <SocketAsyncEventArgs>(socketArgsList); } } catch (Exception ex) { Logger.Info("Failed Server Init"); Logger.Error("Out Of Memory! Reset MaxConnectCount!"); Logger.Error(ex.ToString()); return(false); } return(true); }
public SessionBase(Socket socket, SocketAsyncEventArgs recvSAEA, SocketAsyncEventArgs sendSAEA, PooledBufferManager pooledBufferManager) { m_socket = socket; m_saeaReciver = recvSAEA; m_saeaSender = sendSAEA; m_saeaReciver.UserToken = this; m_saeaSender.UserToken = this; m_pooledBufferManager = pooledBufferManager; DateTime dateTimeNow = DateTime.Now; m_dateStartTime = dateTimeNow; m_dateLastActiveTime = dateTimeNow; }