예제 #1
0
 public PacketToken(SocketAsyncEventArgs args)
 {
     args.UserToken = this;
     PacketBuffer = new PacketBuffer(args);
     Header = new byte[PacketBuffer.HeaderSize];
     TokenID = m_NextTokenId;
     m_NextTokenId++;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SocketAsyncEventArgsPool"/> class with
 /// the specified capacity.
 /// </summary>
 /// <param name="capacity">Max capacity of the pool.</param>
 public SocketAsyncEventArgsPool(int capacity)
 {
     Capacity = capacity;
     Pool = new Stack<SocketAsyncEventArgs>(capacity);
     for (int i = 0; i < capacity; i++)
     {
         var args = new SocketAsyncEventArgs();
         var packetBuffer = new PacketBuffer(args);
         Push(args);
     }
 }