Ejemplo n.º 1
0
 public SimpleTcpAdapter(Socket sc)
 {
     _sc = sc;
     _ReadEventArgs = InitEventArgs(OnReadCompleted);
     _WriteEventArgs = InitEventArgs(OnWriteCompleted);
     try {
         sc.IOControl(keepAlive, inValue, null);
     }
     catch {
     }
     var index = Interlocked.Increment(ref __ii);
     index = Math.Abs(index) % _schs.Length;
     _wsch = _schs[index];
 }
Ejemplo n.º 2
0
 static SimpleTcpAdapter()
 {
     var cnt = Environment.ProcessorCount;
     if (cnt <= 0) {
         cnt = 1;
     }
     else if (cnt > 20) {
         cnt = 20;
     }
     _schs = new Sch[cnt];
     for (int i = 0; i < cnt; i++) {
         _schs[i] = new Sch(1);
     }
 }