int m_totalBytesRead; // counter of the total # bytes received by the server #endregion Fields #region Constructors /// <summary> /// Create an uninitialized server instance. To start the server listening for connection requests /// call the Init method followed by Start method /// </summary> /// <param name="numConnections">the maximum number of connections the sample is designed to handle simultaneously</param> /// <param name="receiveBufferSize">buffer size to use for each socket I/O operation</param> public MMServer(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(receiveBufferSize * numConnections * opsToPreAlloc, receiveBufferSize); m_readWritePool = new SocketAsyncEventArgsPool(numConnections); m_maxNumberAcceptedClients = new Semaphore(numConnections, numConnections); }
/// <summary> /// Create an uninitialized server instance. To start the server listening for connection requests /// call the Init method followed by Start method /// </summary> /// <param name="numConnections">the maximum number of connections the sample is designed to handle simultaneously</param> /// <param name="receiveBufferSize">buffer size to use for each socket I/O operation</param> public PlayerInputServer(int numConnections, int receiveBufferSize, MainInterface myParent, int myPlayerID) { _myParent = myParent; mode = _myParent.mode; playerID = BitConverter.GetBytes(myPlayerID)[0]; logFilePath = "player_" + playerID + ".log"; 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(receiveBufferSize * numConnections * opsToPreAlloc, receiveBufferSize); m_readWritePool = new SocketAsyncEventArgsPool(numConnections); m_maxNumberAcceptedClients = new Semaphore(numConnections, numConnections); analogLoc[0] = new int[] { 0, 0 }; analogLoc[1] = new int[] { 0, 0 }; }