LumiSoft.Net.Dns.Client.DnsServerResponse.GetARecords C# (CSharp) Method

GetARecords() public method

Gets IPv4 host addess records.
public GetARecords ( ) : LumiSoft.Net.Dns.Client.A_Record[]
return LumiSoft.Net.Dns.Client.A_Record[]
        public A_Record[] GetARecords()
        {
            return (A_Record[])FilterRecords(m_pAnswers,typeof(A_Record)).ToArray(typeof(A_Record));
        }

Usage Example

Example #1
0
        /// <summary>
        /// Gets specified host IP addresses(A and AAAA).
        /// </summary>
        /// <param name="host">Host name.</param>
        /// <returns>Returns specified host IP addresses.</returns>
        /// <exception cref="ArgumentNullException">Is raised when <b>host</b> is null reference.</exception>
        public IPAddress[] GetHostAddresses(string host)
        {
            if (host == null)
            {
                throw new ArgumentNullException("host");
            }

            List <IPAddress> retVal = new List <IPAddress>();

            // This is probably NetBios name
            if (host.IndexOf(".") == -1)
            {
                return(System.Net.Dns.GetHostEntry(host).AddressList);
            }
            else
            {
                DnsServerResponse response = Query(host, QTYPE.A);
                if (response.ResponseCode != RCODE.NO_ERROR)
                {
                    throw new DNS_ClientException(response.ResponseCode);
                }

                foreach (DNS_rr_A record in response.GetARecords())
                {
                    retVal.Add(record.IP);
                }

                response = Query(host, QTYPE.AAAA);
                if (response.ResponseCode != RCODE.NO_ERROR)
                {
                    throw new DNS_ClientException(response.ResponseCode);
                }

                foreach (DNS_rr_A record in response.GetARecords())
                {
                    retVal.Add(record.IP);
                }
            }

            return(retVal.ToArray());
        }
All Usage Examples Of LumiSoft.Net.Dns.Client.DnsServerResponse::GetARecords