Esempio n. 1
0
        /// <summary>
        /// Attempts to establish connection to peer.
        /// </summary>
        /// <exception cref="ObjectDisposedException">Cannot connect, <see cref="BroConnection"/> is disposed.</exception>
        /// <exception cref="InvalidOperationException">Failed to connect to host.</exception>
        public void Connect()
        {
            if (m_connectionPtr.IsInvalid())
            {
                throw new ObjectDisposedException("Cannot connect, Bro connection is disposed.");
            }

            // Attempt connection
            if (BroApi.bro_conn_connect(m_connectionPtr) == 0)
            {
                throw new InvalidOperationException(string.Format("Failed to connect to \"{0}\".", m_hostName));
            }
        }