Esempio n. 1
0
 public void PutSocket(NcpClient socket)
 {
     lock (this.socketsQueue)
     {
         if (this.socketsQueue.Count < this.maxConnectionNumber)
         {
             if (socket != null)
             {
                 if (socket.Connected)
                 {
                     this.socketsQueue.Enqueue(socket);
                 }
                 else
                 {
                     socket.Close();
                 }
             }
         }
         else
         {
             socket.Close();
         }
     }
 }
Esempio n. 2
0
 private NcpClient CreateSocket()
 {
     if (socketNumber <= maxConnectionNumber)
     {
         System.Threading.Interlocked.Increment(ref socketNumber);
         var c = new NcpClient();
         return  c;
     }
     throw new Exception("Connection Pool reached its limit");
 }