コード例 #1
0
        /// <summary>
        /// Closes this instance.
        /// </summary>
        public virtual void Close()
        {
            if (m_connection == null)
            {
                return;
            }
            try
            {
                if (m_connection.Connected)
                {
                    NntpReaderWriter.WriteCommand("QUIT");

                    NntpReaderWriter.Dispose();
                    m_nntpStream = null;
                    m_connection.Close();
                }
            }
            finally
            {
                try
                {
                    m_connection.Close();
                }
                catch
                {
                }
                m_connection = null;
            }
        }
コード例 #2
0
        /// <summary>
        /// Opens the specified host name.
        /// </summary>
        /// <param name="hostName">Name of the host.</param>
        /// <param name="port">The port.</param>
        /// <param name="useSsl">Connect with SSL</param>
        protected virtual void Open(string hostName, int port, bool useSsl)
        {
            m_host = hostName;
            m_port = port;
            m_ssl  = useSsl;
            if (string.IsNullOrEmpty(hostName))
            {
                throw new ArgumentNullException("hostName");
            }

            m_connection = new TcpClient(hostName, port);

            if (m_ssl)
            {
                NntpReaderWriter = new NntpProtocolReaderWriter(m_connection, hostName);
            }
            else
            {
                NntpReaderWriter = new NntpProtocolReaderWriter(m_connection);
            }

            if (m_logger != null)
            {
                NntpReaderWriter.LogWriter = m_logger;
            }
            if (ConnectionTimeout != -1)
            {
                m_connection.SendTimeout = m_connection.ReceiveTimeout = ConnectionTimeout;
            }
        }
コード例 #3
0
        /// <summary>
        /// Opens the specified host name.
        /// </summary>
        /// <param name="hostName">Name of the host.</param>
        /// <param name="port">The port.</param>
        protected virtual void Open(string hostName, int port, bool ssl, IProxyClient proxyClient)
        {
            Host = hostName;
            Port = port;
            if (string.IsNullOrEmpty(hostName))
            {
                throw new ArgumentNullException("hostName");
            }
            //ServicePointManager.SetTcpKeepAlive (true, 15 * 1000, 2 * 1000);

            if (proxyClient == null)
            {
                m_connection = new TcpClient(hostName, port);
            }
            else
            {
                m_connection = proxyClient.CreateConnection(hostName, port);
            }

            NntpReaderWriter = new NntpProtocolReaderWriter(m_connection, ssl, hostName);
            if (ConnectionTimeout != -1)
            {
                m_connection.SendTimeout = m_connection.ReceiveTimeout = ConnectionTimeout;
            }
        }
コード例 #4
0
 /// <summary>
 /// Opens the specified host name.
 /// </summary>
 /// <param name="hostName">Name of the host.</param>
 /// <param name="port">The port.</param>
 protected virtual void Open(string hostName, int port, bool ssl)
 {
     m_host = hostName;
     m_port = port;
     if (string.IsNullOrEmpty(hostName))
     {
         throw new ArgumentNullException("hostName");
     }
     //ServicePointManager.SetTcpKeepAlive (true, 15 * 1000, 2 * 1000);
     m_connection     = new TcpClient(hostName, port);
     NntpReaderWriter = new NntpProtocolReaderWriter(m_connection, ssl, hostName);
     if (m_logger != null)
     {
         NntpReaderWriter.LogWriter = m_logger;
     }
     if (ConnectionTimeout != -1)
     {
         m_connection.SendTimeout = m_connection.ReceiveTimeout = ConnectionTimeout;
     }
 }
コード例 #5
0
        /// <summary>
        /// Opens the specified host name.
        /// </summary>
        /// <param name="hostName">Name of the host.</param>
        /// <param name="port">The port.</param>
        /// <param name="useSsl">Connect with SSL</param>
        protected virtual void Open(string hostName, int port, bool useSsl)
        {
            m_host = hostName;
            m_port = port;
            m_ssl = useSsl;
            if (string.IsNullOrEmpty(hostName))
            {
                throw new ArgumentNullException("hostName");
            }

            m_connection = new TcpClient(hostName, port);

            if (m_ssl)
            {
                NntpReaderWriter = new NntpProtocolReaderWriter(m_connection, hostName);
            }
            else
            {
                NntpReaderWriter = new NntpProtocolReaderWriter(m_connection);
            }

            if (m_logger != null)
            {
                NntpReaderWriter.LogWriter = m_logger;
            }
            if (ConnectionTimeout != -1)
            {
                m_connection.SendTimeout = m_connection.ReceiveTimeout = ConnectionTimeout;
            }
        }
コード例 #6
0
        /// <summary>
        /// Closes this instance.
        /// </summary>
        public virtual void Close()
        {
            if (m_connection == null)
            {
                return;
            }
            try
            {
                if (m_connection.Connected)
                {
                    NntpReaderWriter.WriteCommand("QUIT");

                    NntpReaderWriter.Dispose();
                    m_nntpStream = null;
                    m_connection.Close();
                }
            }
            finally
            {
                try
                {
                    m_connection.Close();
                }
                catch
                {
                }
                m_connection = null;
            }
        }