public SocketPool(ServiceContainer container, EndPoint endPoint) { formatter = new BinaryFormatter(); container.Pool = this; poolSize = Int32.Parse(ConfigurationManager.AppSettings["NTS_MIN_POOL_SIZE"]); pooledSockets = new List <PooledSocket>(poolSize); this.container = container; endpoint = endPoint; 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(); Connect(); }
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) }; }
public SocketPool(int poolSize, ServiceContainer owner, string host) { formatter = new BinaryFormatter(); owner.Pool = this; this.poolSize = poolSize; pooledSockets = new List <PooledSocket>(poolSize); container = owner; if (host != null) { endpoint = GetEndPoint(host); } else { throw new ArgumentNullException("Host cannot be null."); } NetworkListener = new NetworkListner(); waitingCallback = new Dictionary <long, WaitCallback>(); waitingContext = new Dictionary <long, object>(); waitHandles = new Dictionary <long, SynchResult>(); waitingCallbackLock = new ReaderWriterLockSlim(); pooledSocketsLock = new ReaderWriterLockSlim(); waitHandlesLock = new ReaderWriterLockSlim(); Connect(); }
public SocketPool(ServiceContainer owner, string host) { formatter = new BinaryFormatter(); owner.Pool = this; poolSize = Int32.Parse(ConfigurationManager.AppSettings["NTS_MIN_POOL_SIZE"]); pooledSockets = new List <PooledSocket>(poolSize); container = owner; if (host != null) { endpoint = GetEndPoint(host); } else { throw new ArgumentNullException("Host cannot be null."); } NetworkListener = new NetworkListner(); waitingCallback = new Dictionary <long, WaitCallback>(); waitingContext = new Dictionary <long, object>(); waitHandles = new Dictionary <long, SynchResult>(); waitingCallbackLock = new ReaderWriterLockSlim(); waitHandlesLock = new ReaderWriterLockSlim(); pooledSocketsLock = new ReaderWriterLockSlim(); Connect(); }