/// <summary> /// 获取实例AsyncReadWrite /// </summary> /// <returns></returns> public static AsyncReadWrite GetInstance() { if (instance == null) { ThreadPool.SetMaxThreads(Config.ThreadPoolSize, Config.ThreadPoolSize); //设置线程池最大值 status = ThreadPoolStatus.Start; //线程现状状态 instance = new AsyncReadWrite(); return(instance); } else { return(instance); } }
public Connection(ServicePoint servicePoint) { _state = 0; _servicePoint = servicePoint; _saea = SaeaPool.Default.GetSaea(); _buffer = BufferPool.Default.GetBuffer(); _socket = new Socket(servicePoint.HostEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp); _socket.NoDelay = !servicePoint.UseNagleAlgorithm; if (_servicePoint.IsSecured) { _asyncReadWrite = new SslAsyncReadWrite(servicePoint.Address.Host, _socket, _saea, servicePoint.ClientCertificate, ValidateServerCertificate); } else { _asyncReadWrite = new AsyncReadWrite(_socket, _saea); } }