Exemple #1
0
        /// <summary>
        /// Creates a new <see cref="BroConnection"/> using the existing <paramref name="socket"/> handle.
        /// </summary>
        /// <param name="socket">Existing open socket to use for <see cref="BroConnection"/>.</param>
        /// <param name="flags">Connection flags for this <see cref="BroConnection"/>.</param>
        /// <exception cref="OutOfMemoryException">Failed to create Bro connection.</exception>
        public BroConnection(int socket, BroConnectionFlags flags = BroConnectionFlags.None)
            : this()
        {
            m_connectionPtr = BroApi.bro_conn_new_socket(socket, flags);

            if (m_connectionPtr.IsInvalid())
            {
                throw new OutOfMemoryException("Failed to create Bro connection.");
            }

            m_hostName = string.Format("@FD={0}", socket);
            m_flags    = flags;
        }
Exemple #2
0
        public BroConnection(Socket socket, BroConnectionFlags flags = BroConnectionFlags.None)
            : this()
        {
            if ((object)socket == null)
            {
                throw new ArgumentNullException("socket");
            }

            m_connectionPtr = BroApi.bro_conn_new_socket(socket.Handle.ToInt32(), flags);

            if (m_connectionPtr.IsInvalid())
            {
                throw new OutOfMemoryException("Failed to create Bro connection.");
            }

            m_hostName = DeriveHostName(socket);
            m_flags    = flags;
        }