Ejemplo n.º 1
0
 public SocketServer()
 {
     readWritePool = new SocketAsyncEventArgsPool(Constants.MaxConnections);
     SocketAsyncEventArgs readWriteEventArg;
     for (int i = 0; i < Constants.MaxConnections; i++)
     {
         readWriteEventArg = new SocketAsyncEventArgs();
         readWriteEventArg.Completed += new EventHandler<SocketAsyncEventArgs>(IO_Completed);
         readWriteEventArg.SetBuffer(new byte[Constants.BufferSize], 0, Constants.BufferSize);
         readWriteEventArg.UserToken = new SocketClient();
         readWritePool.Push(readWriteEventArg);
     }
 }