Exemplo n.º 1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="numConcurrence"></param>
 /// <param name="receiveBufferSize"></param>
 public SocketListener(int numConcurrence, int receiveBufferSize)
 {
     this.m_serverState              = SocketServerState.Initialing;
     this.m_numConnections           = 0;
     this.m_numConcurrence           = numConcurrence;
     this.m_bufferManager            = new SocketBufferManager(receiveBufferSize * numConcurrence * m_opsToPreAlloc, receiveBufferSize);
     this.m_readWritePool            = new SocketAsyncEventArgsPool(numConcurrence);
     this.m_semaphoreAcceptedClients = new Semaphore(numConcurrence, numConcurrence);
 }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="hostName"></param>
        /// <param name="port"></param>
        public SocketClient(string hostName, int port)
        {
            IPHostEntry host = Dns.GetHostEntry(hostName);

            IPAddress[] addressList = host.AddressList;
            this.hostEndPoint    = new IPEndPoint(addressList[addressList.Length - 1], port);
            this.clientSocket    = new Socket(this.hostEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
            this.m_bufferManager = new SocketBufferManager(32768, 32768);
        }
Exemplo n.º 3
0
 public void Dispose()
 {
     m_bufferManager.Dispose();
     m_bufferManager = null;
     m_readWritePool.Dispose();
     m_readWritePool = null;
     try
     {
         m_listenSocket.Shutdown(SocketShutdown.Both);
         m_listenSocket.Close();
     }
     catch
     {
     }
 }