Exemplo n.º 1
0
 internal void RemoveSocket(PooledSocket socket)
 {
     pooledSocketsLock.EnterWriteLock();
     try
     {
         if (pooledSockets != null)
         {
             pooledSockets.Remove(socket);
             socket.Close();
         }
     }
     finally
     {
         pooledSocketsLock.ExitWriteLock();
     }
 }
Exemplo n.º 2
0
 internal SocketPool(ServiceContainer container, Socket socket)
 {
     formatter           = new BinaryFormatter();
     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)
     };
 }
Exemplo n.º 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");
            }
        }
Exemplo n.º 4
0
        internal void MessageError(PooledSocket socket, Exception e)
        {
//			Log.WriteDebug("Error when deserialzize message from host:  " + e);
        }