示例#1
0
 internal void RemoveSocket(PooledSocket socket)
 {
     pooledSocketsLock.EnterWriteLock();
     try
     {
         if (pooledSockets != null)
         {
             pooledSockets.Remove(socket);
             socket.Close();
         }
     }
     finally
     {
         pooledSocketsLock.ExitWriteLock();
     }
 }
示例#2
0
 internal SocketPool(ServiceContainer container, Socket socket)
 {
     formatter           = new TotalFormatter(1000);
     container.Pool      = this;
     connected           = true;
     poolSize            = 1;
     this.container      = container;
     endpoint            = socket.RemoteEndPoint;
     NetworkListener     = new NetworkListner();
     waitingCallback     = new Dictionary <long, WaitCallback>();
     waitingContext      = new Dictionary <long, object>();
     waitingCallbackLock = new ReaderWriterLockSlim();
     waitHandles         = new Dictionary <long, SynchResult>();
     waitHandlesLock     = new ReaderWriterLockSlim();
     pooledSocketsLock   = new ReaderWriterLockSlim();
     pooledSockets       = new List <PooledSocket>(poolSize)
     {
         PooledSocket.CreateNewSocket(socket, this, formatter)
     };
 }
示例#3
0
        public void Request(Request request)
        {
            if (!connected)
            {
                connected = Connect();
                if (!connected)
                {
                    throw new ApplicationException("Pool not connected.");
                }
            }
            PooledSocket socket = Acquire();

            if (socket != null)
            {
                socket.Send(request);
            }
            else
            {
                Log.WriteLog("NTSock: Acquire null socket");
            }
        }
示例#4
0
        internal void MessageError(PooledSocket socket, Exception e)
        {
//			Log.WriteDebug("Error when deserialzize message from host:  " + e);
        }