AsyncSocketSample.Server.Server C# (CSharp) Method

Server() public method

Create an uninitialized server instance. To start the server listening for connection requests call the Init method followed by Start method
public Server ( int numConnections, int receiveBufferSize ) : System
numConnections int the maximum number of connections the sample is designed to handle simultaneously
receiveBufferSize int buffer size to use for each socket I/O operation
return System
        public Server(int numConnections, int receiveBufferSize)
        {
            m_totalBytesRead = 0;
            m_numConnectedSockets = 0;
            m_numConnections = numConnections;
            m_receiveBufferSize = receiveBufferSize;
            // allocate buffers such that the maximum number of sockets can have one outstanding read and
            //write posted to the socket simultaneously
            m_bufferManager = new BufferManager(m_receiveBufferSize * m_numConnections * opsToPreAlloc,
                m_receiveBufferSize);

            m_readWritePool = new SocketAsyncEventArgsPool(m_numConnections);
            m_maxNumberAcceptedClients = new Semaphore(m_numConnections, m_numConnections);
        }