Exemple #1
0
 void ProcessConnect(SocketAsyncEventArgs e)
 {
     if (e.LastOperation == SocketAsyncOperation.Connect && e.SocketError == SocketError.Success)
     {
         // @TODO: 连接成功
     }
     eventArgsPool.TryEnqueue(e);
 }
Exemple #2
0
 public Bootstrap()
 {
     eventArgsPool = new SynchronizedQueue <SocketAsyncEventArgs>();
     for (int i = 0; i < 4; ++i)
     {
         SocketAsyncEventArgs eventArgs = new SocketAsyncEventArgs();
         eventArgs.Completed += new EventHandler <SocketAsyncEventArgs>(IOCompleted);
         eventArgsPool.TryEnqueue(eventArgs);
     }
 }