internal void RemoveSocket(PooledSocket socket) { pooledSocketsLock.EnterWriteLock(); try { if (pooledSockets != null) { pooledSockets.Remove(socket); socket.Close(); } } finally { pooledSocketsLock.ExitWriteLock(); } }
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) }; }
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"); } }
internal void MessageError(PooledSocket socket, Exception e) { // Log.WriteDebug("Error when deserialzize message from host: " + e); }